Although it is a legacy compat.v1 API, this symbol is compatible with eager
execution and tf.function.
To switch to TF2, switch to using either
tf.initializers.RandomNormal or tf.keras.initializers.RandomNormal
(neither from compat.v1) and
pass the dtype when calling the initializer. Keep in mind that
the default stddev and the behavior of fixed seeds have changed.
[[["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 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.random_normal_initializer\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/init_ops.py#L487-L574) |\n\nInitializer that generates tensors with a normal distribution.\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.random_normal`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/random_normal_initializer)\n\n\u003cbr /\u003e\n\n tf.compat.v1.random_normal_initializer(\n mean=0.0,\n stddev=1.0,\n seed=None,\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\nAlthough it is a legacy [`compat.v1`](../../../tf/compat/v1) API, this symbol is compatible with eager\nexecution and [`tf.function`](../../../tf/function).\n\nTo switch to TF2, switch to using either\n`tf.initializers.RandomNormal` or [`tf.keras.initializers.RandomNormal`](../../../tf/keras/initializers/RandomNormal)\n(neither from [`compat.v1`](../../../tf/compat/v1)) and\npass the dtype when calling the initializer. Keep in mind that\nthe default stddev and the behavior of fixed seeds have changed.\n\n#### Structural Mapping to TF2\n\nBefore: \n\n initializer = tf.compat.v1.random_normal_initializer(\n mean=mean,\n stddev=stddev,\n seed=seed,\n dtype=dtype)\n\n weight_one = tf.Variable(initializer(shape_one))\n weight_two = tf.Variable(initializer(shape_two))\n\nAfter: \n\n initializer = tf.initializers.RandomNormal(\n mean=mean,\n seed=seed,\n stddev=stddev)\n\n weight_one = tf.Variable(initializer(shape_one, dtype=dtype))\n weight_two = tf.Variable(initializer(shape_two, dtype=dtype))\n\n#### How to Map Arguments\n\n| TF1 Arg Name | TF2 Arg Name | Note |\n|------------------|--------------|------------------------------------------------------------------------------|\n| `mean` | `mean` | No change to defaults |\n| `stddev` | `stddev` | Default changes from 1.0 to 0.05 |\n| `seed` | `seed` | |\n| `dtype` | `dtype` | The TF2 native api only takes it as a `__call__` arg, not a constructor arg. |\n| `partition_info` | - | (`__call__` arg in TF1) Not supported. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDescription\n-----------\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|------------------------------------------------------------------------------------------------------------------------------------------|\n| `mean` | a python scalar or a scalar tensor. Mean of the random values to generate. |\n| `stddev` | a python scalar or a scalar tensor. Standard deviation of the random values to generate. |\n| `seed` | A Python integer. Used to create random seeds. See [`tf.compat.v1.set_random_seed`](../../../tf/compat/v1/set_random_seed) for behavior. |\n| `dtype` | Default data type, used if no `dtype` argument is provided when calling the initializer. Only floating point types are supported. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `from_config`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.16.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.16.1/tensorflow/python/ops/init_ops.py#L568-L574) \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.16.1/tensorflow/python/ops/init_ops.py#L562-L566) \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"]]