Clears the default graph stack and resets the global default graph.
tf.compat.v1.reset_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.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.compat.v1.reset_default_graph\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/framework/ops.py#L4985-L5012) |\n\nClears the default graph stack and resets the global default graph. \n\n tf.compat.v1.reset_default_graph()\n\n\u003cbr /\u003e\n\nMigrate to TF2\n--------------\n\n\u003cbr /\u003e\n\n| **Caution:** This API was designed for TensorFlow v1. Continue reading for details on how to migrate from this API to a native TensorFlow v2 equivalent. See the [TensorFlow v1 to TensorFlow v2 migration guide](https://www.tensorflow.org/guide/migrate) for instructions on how to migrate the rest of your code.\n\n`reset_default_graph` does not work with either eager execution or\n[`tf.function`](../../../tf/function), and you should not invoke it directly. To migrate code that\nuses Graph-related functions to TF2, rewrite the code without them. See the\n[migration guide](https://www.tensorflow.org/guide/migrate) for more\ndescription about the behavior and semantic changes between Tensorflow 1 and\nTensorflow 2.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDescription\n-----------\n\n| **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`](../../../tf/compat/v1/Session) or [`tf.compat.v1.InteractiveSession`](../../../tf/compat/v1/InteractiveSession) is active will result in undefined behavior. Using any previously created [`tf.Operation`](../../../tf/Operation) or [`tf.Tensor`](../../../tf/Tensor) objects after calling this function will result in undefined behavior.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|------------------|---------------------------------------------------|\n| `AssertionError` | If this function is called within a nested graph. |\n\n\u003cbr /\u003e"]]