I\'m running the cifar10 network on my PC and after finishing the training and running eval script the following error appears:
2016-06-01 14:37:14.238317: p
Looking at the code you posted, the problem is between lines 50 and 51 in eval_once()
:
with tf.Session() as sess:
ckpt = tf.train.get_checkpoint_state(FLAGS.checkpoint_dir)
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess, ckpt.model_checkpoint_path)
global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
else:
print('No checkpoint file found')
return
# <<< The Session is closed here >>>
coord = tf.train.Coordinator()
try:
# ...
When the code exits a with tf.Session() as sess:
block, sess
is automatically closed, and you cannot use it any more. There are (at least) two ways to fix this problem:
Indent lines 51 through 76 by 4 spaces, so that they are also inside the with
block.
Create the session without using a with
block and close it manually:
def eval_once():
sess = tf.Session()
ckpt = tf.train.get_checkpoint_state(FLAGS.checkpoint_dir)
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess, ckpt.model_checkpoint_path)
global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
else:
print('No checkpoint file found')
sess.close()
return
coord = tf.train.Coordinator()
try:
# ...
finally:
sess.close()