<br />

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

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

    tf.compat.v1.reset_default_graph() -> None

<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/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

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Generating Images with BigGAN](https://www.tensorflow.org/hub/tutorials/biggan_generation_with_tf_hub) - [Classify Flowers with Transfer Learning](https://www.tensorflow.org/hub/tutorials/image_feature_vector) - [Generating Images with Little Data Using S3GAN](https://www.tensorflow.org/hub/tutorials/s3gan_generation_with_tf_hub) - [Fitting Dirichlet Process Mixture Model Using Preconditioned Stochastic Gradient Langevin Dynamics](https://www.tensorflow.org/probability/examples/Fitting_DPMM_Using_pSGLD) - [Linear Mixed-Effect Regression in {TF Probability, R, Stan}](https://www.tensorflow.org/probability/examples/HLM_TFP_R_Stan) |

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