<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#L9280-L9308) |

Return a 2-D tensor with ones on the diagonal and zeros elsewhere.

#### View aliases


**Main aliases**

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

<br />

    tf.keras.ops.eye(
        N, M=None, k=0, dtype=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `N` | Number of rows in the output. |
| `M` | Number of columns in the output. If `None`, defaults to `N`. |
| `k` | Index of the diagonal: 0 (the default) refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal. |
| `dtype` | Data type of the returned tensor. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Tensor with ones on the k-th diagonal and zeros elsewhere. ||

<br />