tf.sparse.eye

View source on GitHub

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

tf.sparse.eye(
    num_rows, num_columns=None, dtype=tf.dtypes.float32, name=None
)

Args:

Returns:

A SparseTensor of shape [num_rows, num_columns] with ones along the diagonal.