mindspore.ops.Eye

class mindspore.ops.Eye[source]

Creates a tensor with ones on the diagonal and zeros in the rest.

Refer to mindspore.ops.eye() for more details.

Supported Platforms:

Ascend GPU CPU

Examples

>>> eye = ops.Eye()
>>> output = eye(2, 2, mindspore.int32)
>>> print(output)
[[1 0]
 [0 1]]
>>> print(output.dtype)
Int32
>>> output = eye(1, 2, mindspore.float64)
>>> print(output)
[[1. 0.]]
>>> print(output.dtype)
Float64