machrisaa / tensorflow-vgg

VGG19 and VGG16 on Tensorflow
2.21k stars 1.08k forks source link

How to print current accuracy and error? #14

Closed aryopg closed 7 years ago

aryopg commented 7 years ago

I'm actually new to tensorflow, i don't know how to show the accuracy and error from the vgg19_trainable code each training. Thanks in advance

machrisaa commented 7 years ago

Hi @aryopg, vgg19_trainable is a trainable pre-trained network and there is no code for training attached to this project. The main objective of this project is to provide pre-trained VGG for usage like transfer training or acting as cost function in image synthesis.

You can find more discussion abut how to train the network in here and here.

If you are new to Tensoflow, it is good to start with the official tutorial to understand the concept about how the computations of Tensors are submitted to the native environment and return back to python.

aryopg commented 7 years ago

I'm so sorry for my non-expert question, but i have these questions in my mind:

  1. If i change the last fc layer, then i can actually (sort of) retrain the network for my purpose, right?
  2. How to see the accuracy for each epoch/iteration? I hope you can be patient with my knowledge lackness
machrisaa commented 7 years ago

Please don't get me wrong. You are welcome to ask questions :)

  1. Yes, you can train the last fc layer (or all the fc layers) in order retain it to do different things. In this case, you can still keep using the ability of the conv layers to analysis the features of the image. And then formulate different outcomes based on your new training.

  2. To see the accuracy of an iteration, you can define a cost function in your training. I have an example in this project here. If you execute the cost with a session and then print it out, it could be an index of the "accuracy" of your training.

aryopg commented 7 years ago

I currently training 25.000-ish data with 8 as batch_size and now i'm entering 800th training step. Is it normal for the accuracy to stay in 0.0305344. I'm afraid that i wait for something that won't improve

aryopg commented 7 years ago

Oh i also want to ask, how to execute the cost with a session? is it like this: sess.run(cost, feed_dict={images: train_image_batch.eval(), true_out: train_label_batch.eval(), train_mode: True})

machrisaa commented 7 years ago

I currently training 25.000-ish data with 8 as batch_size and now i'm entering 800th training step. Is it normal for the accuracy to stay in 0.0305344. I'm afraid that i wait for something that won't improve

What is your cost function?

Oh i also want to ask, how to execute the cost with a session? is it like this: sess.run(cost, feed_dict={images: train_image_batch.eval(), true_out: train_label_batch.eval(), train_mode: True})

Yes. You can print the cost like this:

cost_out = sess.run( cost, feed_dict=...)
print( cost_out )
aryopg commented 7 years ago

i use the same cost function with your code : cost = tf.reduce_sum((vgg.prob - true_out) ** 2)

machrisaa commented 7 years ago

Which optimizer are you using? Do you mind to show me the whole code that you used to train the network?

aryopg commented 7 years ago

i use gradient descent with 0.0001 learning rate. May i know your personal email to send the code?

aryopg commented 7 years ago

Hi chris, i've changed the optimizer into adam and it's working really well. Thanks for the support. Will contact you again if i have another problem :)

machrisaa commented 7 years ago

No problem

aryopg commented 7 years ago

btw i want to send the code to you to be checked. May i get your email?

aryopg commented 7 years ago

I actually got a weird stuff going on, i was trying to modify the optimizer learning rate and i got 8.0 accuracy 1 is the highest. Can you check my code?

usmanxia commented 5 years ago

@aryopg Sorry for invoking the post again but can you share your code for training. I am trying to train the network but getting loss 2.0 consistently. Thank you and really appreciate your response.