tensorflow / 2.9.1 / compat / v1 / reset_default_graph.html /

tf.compat.v1.reset_default_graph

Clears the default graph stack and resets the global default graph.

Migrate to TF2

reset_default_graph does not work with either eager execution or tf.function, and you should not invoke it directly. To migrate code that uses Graph-related functions to TF2, rewrite the code without them. See the migration guide for more description about the behavior and semantic changes between Tensorflow 1 and Tensorflow 2.

Description

Note: The default graph is a property of the current thread. This function applies only to the current thread. Calling this function while a tf.compat.v1.Session or tf.compat.v1.InteractiveSession is active will result in undefined behavior. Using any previously created tf.Operation or tf.Tensor objects after calling this function will result in undefined behavior.
Raises
AssertionError If this function is called within a nested graph.

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/compat/v1/reset_default_graph