Reputation: 10983
I am restoring variables into a graph in one session, closing the session and then creating a new session where I attempt to evaluate the graph. When doing so I get the error FailedPreconditionError: Attempting to use uninitialized value ...
.
Attempting to evaluate the graph in the first session works fine.
Calling sess.run(tf.global_variables_initializer())
on the second session "fixes" the problem, however it resets the variables' values.
The initial restoration is done using:
meta_graph_def = meta_graph.read_meta_graph_file(meta_graph_filename)
saver = tf.train.import_meta_graph(meta_graph_def)
sess = tf.Session(target=target, config=config)
saver.restore(sess, save_path)
Upvotes: 3
Views: 44
Reputation: 10983
According to https://www.tensorflow.org/programmers_guide/faq:
What is the lifetime of a variable?
A variable is created when you first run the tf.Variable.initializer operation for that variable in a session. It is destroyed when that tf.Session.close.
So it seems that the variable cannot be used across a Session.close
.
Upvotes: 2