[[["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.random_uniform_initializer\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#L397-L484) |\n\nInitializer that generates tensors with a uniform 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_uniform`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/random_uniform_initializer)\n\n\u003cbr /\u003e\n\n tf.compat.v1.random_uniform_initializer(\n minval=0.0,\n maxval=None,\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 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.RandomUniform`](../../../tf/keras/initializers/RandomUniform) or [`tf.keras.initializers.RandomUniform`](../../../tf/keras/initializers/RandomUniform)\n(neither from [`compat.v1`](../../../tf/compat/v1)) and\npass the dtype when calling the initializer. Keep in mind that\nthe default minval, maxval and the behavior of fixed seeds have changed.\n\n#### Structural Mapping to TF2\n\nBefore: \n\n initializer = tf.compat.v1.random_uniform_initializer(\n minval=minval,\n maxval=maxval,\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.RandomUniform(\n minval=minval,\n maxval=maxval,\n seed=seed)\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| `minval` | `minval` | Default changes from 0 to -0.05 |\n| `maxval` | `maxval` | 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| `minval` | A python scalar or a scalar tensor. Lower bound of the range of random values to generate. |\n| `maxval` | A python scalar or a scalar tensor. Upper bound of the range of random values to generate. Defaults to 1 for float types. |\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. |\n\n\u003cbr /\u003e\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#L478-L484) \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#L472-L476) \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"]]