def evaluate():
"""Eval CNN for a number of steps."""
with tf.Graph().as_default() as g, tf.device("/cpu:0"):
# Get sequences and labels
sequences, labels = model.inputs_eval()
# Build a Graph that computes the logits predictions from the
# inference model.
logits = model.inference(sequences)
# Calculate predictions.
top_k_op = tf.nn.in_top_k(logits, labels, 1)
# # Restore the moving average version of the learned variables for eval.
# variable_averages = tf.train.ExponentialMovingAverage(
# model.MOVING_AVERAGE_DECAY)
# variables_to_restore = variable_averages.variables_to_restore()
# saver = tf.train.Saver(variables_to_restore)
saver = tf.train.Saver(tf.all_variables())
# Build the summary operation based on the TF collection of Summaries.
summary_op = tf.merge_all_summaries()
summary_writer = tf.train.SummaryWriter(EVAL_DIR, g)
while True:
eval_once(saver, summary_writer, top_k_op, summary_op)
if FLAGS.run_once:
print("eval only once, stope eval")
break
print("sleep for {} seconds".format(FLAGS.eval_interval_secs))
time.sleep(FLAGS.eval_interval_secs)
评论列表
文章目录