I am trying to restore graph from a checkpoint. The checkpoint is created by tf.Supervisor
. There are both meta
file and checkpoint.
What I try to achive is to load this graph from separate application to run some operation (i.e. resue existing model).
I do this as the following (as explained here: https://www.tensorflow.org/api_docs/python/tf/train/import_meta_graph):
meta = 'path/to/file.meta'
my_graph = tf.Graph()
with my_graph.as_default():
with tf.Session() as sess:
saver = tf.train.import_meta_graph(meta)
saver.restore(sess, tf.train.latest_checkpoint(os.path.dirname(meta)))
op = my_graph.get_operation_by_name("op")
print(sess.run(op))
What I see is None
. What I expect to see is 1-D Tensor.
I inspected my_graph
object using get_collection and find that there are all my variables required for op
to run correctly initialized with values restored from the checkpoint.
How can I figure out why the operation is not evaluated correctly? I am really stuck here.
The following code:
print(sess.run(my_graph.get_operation_by_name("Variable_2")))
print(sess.run(my_graph.get_tensor_by_name("Variable_2:0")))
prints
None
4818800
as if there is no connection between an operation and corresponding variable.