def add_evaluation_step(graph, final_tensor_name, ground_truth_tensor_name):
"""Inserts the operations we need to evaluate the accuracy of our results.
Args:
graph: Container for the existing model's Graph.
final_tensor_name: Name string for the new final node that produces results.
ground_truth_tensor_name: Name string for the node we feed ground truth data
into.
Returns:
Nothing.
"""
result_tensor = graph.get_tensor_by_name(ensure_name_has_port(
final_tensor_name))
ground_truth_tensor = graph.get_tensor_by_name(ensure_name_has_port(
ground_truth_tensor_name))
correct_prediction = tf.equal(
tf.argmax(result_tensor, 1), tf.argmax(ground_truth_tensor, 1))
evaluation_step = tf.reduce_mean(tf.cast(correct_prediction, 'float'))
return evaluation_step
评论列表
文章目录