<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/ops/variables.py#L1995-L2011) |

Returns an Op that initializes all local variables.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.initializers.local_variables`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/local_variables_initializer)

<br />

    tf.compat.v1.local_variables_initializer()

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

In TF2, variables are initialized immediately when they are created. There is
no longer a need to run variable initializers before using them.

<br />

<br />

## Description

This is just a shortcut for `variables_initializer(local_variables())`

<br />

<br />

<br />

| ## Returns ||
|---|---|
| An Op that initializes all local variables in the graph. ||

<br />