# tf.compat.v1.variables_initializer

<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/ops/variables.py#L1857-L1885) |

Returns an Op that initializes a list of variables.

#### View aliases


**Compat aliases for migration**

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

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

<br />

    tf.compat.v1.variables_initializer(
        var_list, name='init'
    )

<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

After you launch the graph in a session, you can run the returned Op to
initialize all the variables in `var_list`. This Op runs all the
initializers of the variables in `var_list` in parallel.

Calling `initialize_variables()` is equivalent to passing the list of
initializers to `Group()`.

If `var_list` is empty, however, the function still returns an Op that can
be run. That Op just has no effect.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `var_list` | List of `Variable` objects to initialize. |
| `name` | Optional name for the returned operation. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| An Op that run the initializers of all the specified variables. ||

<br />