# tf.experimental.numpy.experimental_enable_numpy_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/ops/numpy_ops/np_config.py#L23-L46) |

Enable NumPy behavior on Tensors.

    tf.experimental.numpy.experimental_enable_numpy_behavior(
        prefer_float32=False
    )

Enabling NumPy behavior has three effects:

- It adds to [`tf.Tensor`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/Tensor) some common NumPy methods such as `T`, `reshape` and `ravel`.
- It changes dtype promotion in [`tf.Tensor`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/Tensor) operators to be compatible with NumPy. For example, `tf.ones([], tf.int32) + tf.ones([], tf.float32)` used to throw a "dtype incompatible" error, but after this it will return a float64 tensor (obeying NumPy's promotion rules).
- It enhances [`tf.Tensor`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/Tensor)'s indexing capability to be on par with [NumPy's](https://numpy.org/doc/stable/reference/arrays.indexing.html).

<br />

<br />

<br />

| ## Args ||
|---|---|
| `prefer_float32` | Controls whether dtype inference will use float32 for Python floats, or float64 (the default and the NumPy-compatible behavior). |

<br />