I am trying to use Tensorboard to visualize my training procedure. My purpose is, when every epoch completed, I would like to test the network's accuracy using the whole validation dataset, and store this accuracy result into a summary file, so that I can visualize it in Tensorboard.
I know Tensorflow has summary_op
to do it, however it seems only work for one batch when running the code sess.run(summary_op)
. I need to calculate the accuracy for the whole dataset. How?
Is there any example to do it?
Define a tf.scalar_summary
that accepts a placeholder:
accuracy_value_ = tf.placeholder(tf.float32, shape=())
accuracy_summary = tf.scalar_summary('accuracy', accuracy_value_)
Then calculate the accuracy for the whole dataset (define a routine that calculates the accuracy for every batch in the dataset and extract the mean value) and save it into a python variable, let's call it va
.
Once you have the value of va
, just run the accuracy_summary
op, feeding the accuracy_value_
placeholder:
sess.run(accuracy_summary, feed_dict={accuracy_value_: va})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With