# tf.sparse.eye

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/sparse_ops.py#L241-L272) |

Creates a two-dimensional sparse tensor with ones along the diagonal.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.sparse.eye`](https://www.tensorflow.org/api_docs/python/tf/sparse/eye)

<br />

    tf.sparse.eye(
        num_rows,
        num_columns=None,
        dtype=https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/dtypes#float32,
        name=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `num_rows` | Non-negative integer or `int32` scalar `tensor` giving the number of rows in the resulting matrix. |
| `num_columns` | Optional non-negative integer or `int32` scalar `tensor` giving the number of columns in the resulting matrix. Defaults to `num_rows`. |
| `dtype` | The type of element in the resulting `Tensor`. |
| `name` | A name for this `Op`. Defaults to "eye". |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `SparseTensor` of shape \[num_rows, num_columns\] with ones along the diagonal. ||

<br />