Do not use tf.reset_default_graph() to clear nested graphs
This error message is displayed when you call tf.reset_default_graph()
in one of the following scenarios:
- Inside a
with graph.as_default():
block. - Inside a
with tf.Session():
block. - Between creating a
tf.InteractiveSession
and callingsess.close()
.
Each of these scenarios involves registering a default (and potentially "nested") tf.Graph
object, which will be unregistered when you exit the block (or close the tf.InteractiveSession
). Resetting the default graph in those scenarios would leave the system in an inconsistent state, so you should ensure to exit the block (or close the tf.InteractiveSession
) before calling tf.reset_default_graph()
.