# tf.keras.initializers.Identity

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/init_ops_v2.py#L506-L542) |

Initializer that generates the identity matrix.

Inherits From: [`Initializer`](https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/keras/initializers/Initializer)

#### View aliases


**Main aliases**

[`tf.initializers.Identity`](https://www.tensorflow.org/api_docs/python/tf/keras/initializers/Identity), [`tf.initializers.identity`](https://www.tensorflow.org/api_docs/python/tf/keras/initializers/Identity), [`tf.keras.initializers.identity`](https://www.tensorflow.org/api_docs/python/tf/keras/initializers/Identity)

<br />

    tf.keras.initializers.Identity(
        gain=1.0
    )

Only use for 2D matrices.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `gain` | Multiplicative factor to apply to the identity matrix. |

<br />

## Methods

### `from_config`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/init_ops_v2.py#L69-L89)

    @classmethod
    from_config(
        config
    )

Instantiates an initializer from a configuration dictionary.

#### Example:

    initializer = RandomUniform(-1, 1)
    config = initializer.get_config()
    initializer = RandomUniform.from_config(config)

<br />

<br />

<br />

| Args ||
|---|---|
| `config` | A Python dictionary. It will typically be the output of `get_config`. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An Initializer instance. ||

<br />

### `get_config`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/init_ops_v2.py#L541-L542)

    get_config()

Returns the configuration of the initializer as a JSON-serializable dict.

<br />

<br />

<br />

| Returns ||
|---|---|
| A JSON-serializable Python dict. ||

<br />

### `__call__`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/init_ops_v2.py#L518-L539)

    __call__(
        shape, dtype=tf.dtypes.float32
    )

Returns a tensor object initialized as specified by the initializer.

<br />

<br />

<br />

| Args ||
|---|---|
| `shape` | Shape of the tensor. |
| `dtype` | Optional dtype of the tensor. Only floating point types are supported. |

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If the dtype is not floating point |

<br />