def _check_output_2(gin, tf_input1, tf_input2, expected):
"""
Takes a TFInputGraph object (assumed to have the input and outputs of the given
names above) and compares the outcome against some expected outcome.
"""
graph = tf.Graph()
graph_def = gin.graph_def
with tf.Session(graph=graph) as sess:
tf.import_graph_def(graph_def, name="")
tgt_feed1 = tfx.get_tensor(_tensor_input_name, graph)
tgt_feed2 = tfx.get_tensor(_tensor_input_name_2, graph)
tgt_fetch = tfx.get_tensor(_tensor_output_name, graph)
# Run on the testing target
tgt_out = sess.run(tgt_fetch, feed_dict={tgt_feed1: tf_input1, tgt_feed2: tf_input2})
# Working on integers, the calculation should be exact
assert np.all(tgt_out == expected), (tgt_out, expected)
评论列表
文章目录