<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/numpy.py#L4114-L4128) |

Return the identity tensor.

#### View aliases


**Main aliases**

[`tf.keras.ops.numpy.identity`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/identity)

<br />

    tf.keras.ops.identity(
        n, dtype=None
    )

The identity tensor is a square tensor with ones on the main diagonal and
zeros elsewhere.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `n` | Number of rows (and columns) in the `n x n` output tensor. |
| `dtype` | Data type of the output tensor. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The identity tensor. ||

<br />