I have successfully ported the CIFAR-10 ConvNet tutorial code for my own images and am able to train on my data and generate Tensorboard outputs etc.
My next step was to implement an evaluation of new data against the model I built. I am trying now to use cifar10_eval.py as a starting point however am running into some difficulty.
I should point out that the original tutorial code runs entirely without a problem, including cifar10_eval.py. However, when moving this particular code to my application, I get the following error message (last line).
RuntimeError: Attempted to use a closed Session.
# Check session.
raise RuntimeError('Attempted to use a closed Session.')
def eval_once(args etc)
with tf.Session() as sess:
summary = tf.Summary()
summary.ParseFromString(sess.run(summary_op)) # <========== line 106
summary_op = tf.merge_all_summaries()
eval_once(saver, summary_writer, top_k_op, summary_op)
It was a simple (but humbling) error in indentation.
summary = tf.Summary() summary.ParseFromString(sess.run(summary_op)) summary.value.add(tag='Precision @ 1', simple_value=precision) summary_writer.add_summary(summary, global_step)
was outside of the
try: block, and of course, no session could be found.