[[["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.ones_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#L182-L216) |\n\nInitializer that generates tensors initialized to 1.\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.ones`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/ones_initializer)\n\n\u003cbr /\u003e\n\n tf.compat.v1.ones_initializer(\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\nThis API is compatible with TF2 behavior and [`tf.function`](../../../tf/function), and can be\nmigrated immediately with [`tf.keras.initializers.ones`](../../../tf/keras/initializers/Ones).\n\nBefore: \n\n \u003e\u003e\u003e initializer = tf.compat.v1.keras.initializers.ones()\n \u003e\u003e\u003e initializer((1, 1))\n \u003ctf.Tensor: shape=(1, 1), dtype=float32, numpy=array([[1.]], dtype=float32)\u003e\n\nAfter: \n\n \u003e\u003e\u003e initializer = tf.keras.initializers.ones()\n \u003e\u003e\u003e initializer((1, 1))\n \u003ctf.Tensor: shape=(1, 1), dtype=float32, numpy=array([[1.]], dtype=float32)\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDescription\n-----------\n\n### Used in the notebooks\n\n| Used in the guide |\n|-----------------------------------------------------------------------------------------------|\n| - [Use TF1.x models in TF2 workflows](https://www.tensorflow.org/guide/migrate/model_mapping) |\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#L215-L216) \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#L210-L213) \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"]]