Resetting default graph does not remove variables

后端 未结 1 1760
执念已碎
执念已碎 2021-01-05 14:02

I am looking for a way to quickly change a graph within an interactive session in Jupyter in order to test different structures. Initially I wanted to simple delete existing

相关标签:
1条回答
  • 2021-01-05 14:24

    When you reset the default graph, you do not remove the previous Tensors created. When calling tf.reset_default_graph(), a new graph is created and set to default.

    Here is an example to illustrate:

    x = tf.constant(1)
    print tf.get_default_graph() == x.graph  # prints True
    
    tf.reset_default_graph()
    print tf.get_default_graph() == x.graph  # prints False
    

    The error you had indicates that two tensors must be from the same graph, which means you are still using some tensors from the previous graph AND from the current default graph.

    The easy fix is to create again the two placeholders images_placeholder and points_placeholder

    0 讨论(0)
提交回复
热议问题