To migrate to TF2, please use tf.zerosinitializer instead. The dtype
argument in <a href="../../../../../tf/compat/v1/keras/initializers/Zeros#init_">tf.compat.v1.zerosinitializer.init_() does not exist in
tf.zerosinitializer.init_(). However, you can specify the dtype in
__call__() in both cases.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[],[],null,["# tf.compat.v1.keras.initializers.Zeros\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/init_ops.py#L97-L179) |\n\nInitializer that generates tensors initialized to 0.\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.zeros`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/zeros_initializer), \\`tf.compat.v1.keras.initializers.zeros\\`, [`tf.compat.v1.zeros_initializer`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/zeros_initializer)\n\n\u003cbr /\u003e\n\n tf.compat.v1.keras.initializers.Zeros(\n dtype=../../../../../tf/dtypes#float32\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\n[`tf.compat.v1.zeros_initializer`](../../../../../tf/compat/v1/keras/initializers/Zeros) is compatible with eager execution\nand [`tf.function`](../../../../../tf/function).\n\nTo migrate to TF2, please use [`tf.zeros`*initializer*](../../../../../tf/zeros_initializer)*instead. The `dtype`\nargument in \\\u003ca href=\"../../../../../tf/compat/v1/keras/initializers/Zeros#* *init* _\"\\\u003e`tf.compat.v1.zeros`*initializer.* *init*`_()` does not exist in\n[`tf.zeros`*initializer.* *init*`_()`](../../../../../tf/zeros_initializer#__init__). However, you can specify the `dtype` in\n`__call__()` in both cases.\n\n#### Structural Mapping to TF2\n\nBefore: \n\n initializer = tf.compat.v1.zeros_initializer(dtype=tf.float32)\n variable = tf.Variable(initializer(shape=[3, 3]))\n\nAfter: \n\n initializer = tf.zeros_initializer()\n variable = tf.Variable(initializer(shape=[3, 3], dtype=tf.float32))\n\n#### How to Map Arguments\n\n| TF1 Arg Name | TF2 Arg Name | Note |\n|------------------|--------------|---------------------------------------|\n| `dtype` | `dtype` | In `__call__()` method |\n| `partition_info` | - | (`__call__` arg in TF1) Not supported |\n\n#### Before \\& After Usage Example\n\nBefore: \n\n initializer = tf.compat.v1.zeros_initializer(dtype=tf.float32)\n tf.Variable(initializer(shape=[3])).numpy()\n array([0., 0., 0.], dtype=float32)\n tf.Variable(initializer(shape=[3, 3])).numpy()\n array([[0., 0., 0.],\n [0., 0., 0.],\n [0., 0., 0.]], dtype=float32)\n initializer = tf.compat.v1.zeros_initializer()\n tf.Variable(initializer(shape=[3], dtype=tf.float32)).numpy()\n array([0., 0., 0.], dtype=float32)\n tf.Variable(initializer(shape=[3, 3], dtype=tf.float32)).numpy()\n array([[0., 0., 0.],\n [0., 0., 0.],\n [0., 0., 0.]], dtype=float32)\n\nAfter: \n\n initializer = tf.zeros_initializer()\n tf.Variable(initializer(shape=[3], dtype=tf.float32)).numpy()\n array([0., 0., 0.], dtype=float32)\n tf.Variable(initializer(shape=[3, 3], dtype=tf.float32)).numpy()\n array([[0., 0., 0.],\n [0., 0., 0.],\n [0., 0., 0.]], dtype=float32)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDescription\n-----------\n\nMethods\n-------\n\n### `from_config`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/init_ops.py#L75-L94) \n\n @classmethod\n from_config(\n config\n )\n\nInstantiates an initializer from a configuration dictionary.\n\n#### Example:\n\n initializer = RandomUniform(-1, 1)\n config = initializer.get_config()\n initializer = RandomUniform.from_config(config)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------|-----------------------------------------------------------------------|\n| `config` | A Python dictionary. It will typically be the output of `get_config`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| An Initializer instance. ||\n\n\u003cbr /\u003e\n\n### `get_config`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/init_ops.py#L178-L179) \n\n get_config()\n\nReturns the configuration of the initializer as a JSON-serializable dict.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A JSON-serializable Python dict. ||\n\n\u003cbr /\u003e\n\n### `__call__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/init_ops.py#L173-L176) \n\n __call__(\n shape, dtype=None, partition_info=None\n )\n\nReturns a tensor object initialized as specified by the initializer.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|------------------|--------------------------------------------------------------------------|\n| `shape` | Shape of the tensor. |\n| `dtype` | Optional dtype of the tensor. If not provided use the initializer dtype. |\n| `partition_info` | Optional information about the possible partitioning of a tensor. |\n\n\u003cbr /\u003e"]]