# tf.compat.v1.disable_v2_behavior

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/compat/v2_compat.py#L82-L124) |

Disables TensorFlow 2.x behaviors.

    tf.compat.v1.disable_v2_behavior()

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

Using this function indicates that your software is not compatible
with eager execution and [`tf.function`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/function) in TF2.

To migrate to TF2, rewrite your code to be compatible with eager execution.
Please refer to the [migration guide](https://www.tensorflow.org/guide/migrate) for additional resource on the
topic.

<br />

<br />

## Description

This function can be called at the beginning of the program (before `Tensors`,
`Graphs` or other structures have been created, and before devices have been
initialized. It switches all global behaviors that are different between
TensorFlow 1.x and 2.x to behave as intended for 1.x.

User can call this function to disable 2.x behavior during complex migrations.