# tf.compat.v1.reset_default_graph

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/framework/ops.py#L4985-L5012) |

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

    tf.compat.v1.reset_default_graph()

<br />

## Migrate to TF2

<br />

> [!CAUTION]
> **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.

`reset_default_graph` does not work with either eager execution or
[`tf.function`](https://www.tensorflow.org/versions/r2.14/api_docs/python/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](https://www.tensorflow.org/guide/migrate) for more
description about the behavior and semantic changes between Tensorflow 1 and
Tensorflow 2.

<br />

<br />

## Description

> [!NOTE]
> **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`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/compat/v1/Session) or [`tf.compat.v1.InteractiveSession`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/compat/v1/InteractiveSession) is active will result in undefined behavior. Using any previously created [`tf.Operation`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/Operation) or [`tf.Tensor`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/Tensor) objects after calling this function will result in undefined behavior.

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `AssertionError` | If this function is called within a nested graph. |

<br />