mindspore.ops.Eye

class mindspore.ops.Eye[源代码]

创建一个主对角线上元素为1,其余元素为0的Tensor。

更多参考详见 mindspore.ops.eye()

支持平台:

Ascend GPU CPU

样例:

>>> 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