def _check_output(gin, tf_input, 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_feed = tfx.get_tensor(_tensor_input_name, graph)
tgt_fetch = tfx.get_tensor(_tensor_output_name, graph)
# Run on the testing target
tgt_out = sess.run(tgt_fetch, feed_dict={tgt_feed: tf_input})
# Working on integers, the calculation should be exact
assert np.all(tgt_out == expected), (tgt_out, expected)
# TODO: we could factorize with _check_output, but this is not worth the time doing it.
评论列表
文章目录