Comments (3)
my code here:
# for loop
for index in range(720):
ind=random.randint(0,720)
img=utils.load_image("./03224jpg/file%d.jpg"%ind)
img_true_result=[0,1] if ind%2==0 else [1,0]
batch = img.reshape((1, 224, 224, 3))
print ind
prob = sess.run(vgg.prob, feed_dict={images: batch, train_mode: False})
utils.print_prob(prob[0], './synset.txt')
# simple 1-step training
cost = tf.reduce_sum((vgg.prob - true_out) ** 2)
train = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
sess.run(train, feed_dict={images: batch, true_out: img_true_result, train_mode: True})
# test classification again, should have a higher probability about tiger
prob = sess.run(vgg.prob, feed_dict={images: batch, train_mode: False})
utils.print_prob(prob[0], './synset.txt')
from tensorflow-vgg.
There is a critical error in your code. You should take cost = tf.reduce_sum((vgg.prob - true_out) ** 2)
and train = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
out of the loop.
Apart from the critical issue, I think you don't need to print the prob 2 times in a loop. You also need to make sure you have correctly modified your VGG
, util
, and synset.txt
to produce 2 classification results instead of 1000.
I think you probably copy the logic in test_vgg19_trainable.py
to build your training. Beware that it is just a test runner and NOT a standard code for training a network. I suggest you build one in your case.
If you want to train the model from the initial state, I suggest you read this long discussion here
Usually I would not train the network from scratch. Instead, I will modify the final layers and reuse the pre-trained variables to do a new classification.
from tensorflow-vgg.
thanks a lot
from tensorflow-vgg.
Related Issues (20)
- The vgg16.npy can't be downed. HOT 4
- Relu layer
- _pickle.UnpicklingError HOT 1
- About NPY file
- why there is no activation function behind the convolution layer? HOT 1
- what about more channels
- Train on my own data... HOT 6
- About accuracy of the pretrained vgg.npy
- the padding in maxpooling of the vgg16.py HOT 1
- Do you know how to implement the "use this to build the VGG object", Please?
- about fc_layer
- vgg19_trainable without trainer?
- the issues about split
- Different value from this version and keras HOT 1
- colaboratory
- Tensorflow version problem HOT 2
- npy file for pytorch?
- Google Colab
- Spelling error.
- When I first use this net,where should I spill the code in the "readme-usage" ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorflow-vgg.