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.
Args
var_list
List of Variable objects to initialize.
name
Optional name for the returned operation.
Returns
An Op that run the initializers of all the specified variables.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.variables_initializer\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/variables.py#L1858-L1886) |\n\nReturns an Op that initializes a list of variables.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.initializers.variables`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/variables_initializer)\n\n\u003cbr /\u003e\n\n tf.compat.v1.variables_initializer(\n var_list, name='init'\n )\n\n\u003cbr /\u003e\n\nMigrate to TF2\n--------------\n\n\u003cbr /\u003e\n\n| **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.\n\nIn TF2, variables are initialized immediately when they are created. There is\nno longer a need to run variable initializers before using them.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDescription\n-----------\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|----------------------------------------------------------------------------------------------------------------|\n| - [Tutorial on Multi Armed Bandits in TF-Agents](https://www.tensorflow.org/agents/tutorials/bandits_tutorial) |\n\nAfter you launch the graph in a session, you can run the returned Op to\ninitialize all the variables in `var_list`. This Op runs all the\ninitializers of the variables in `var_list` in parallel.\n\nCalling `initialize_variables()` is equivalent to passing the list of\ninitializers to `Group()`.\n\nIf `var_list` is empty, however, the function still returns an Op that can\nbe run. That Op just has no effect.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|-------------------------------------------|\n| `var_list` | List of `Variable` objects to initialize. |\n| `name` | Optional name for the returned operation. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| An Op that run the initializers of all the specified variables. ||\n\n\u003cbr /\u003e"]]