mindspore/docs/api/api_python/numpy/mindspore.numpy.eye.rst

18 lines
956 B
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.numpy.eye
=================================
.. py:function:: mindspore.numpy.eye(N, M=None, k=0, dtype=mstype.float32)
返回一个对角线上值为1其他位置为0的二维Tensor。
参数:
- **N** (int) - 输出二维Tensor的行数。 输入值必须大于0。
- **M** (int, 可选) - 输出二维Tensor的列数。默认值 ``None`` ,如果输入为 ``None`` ,则默认值: ``N`` 输入值必须大于0。
- **k** (int, 可选) - 对角线的索引。默认值: ``0`` ,即主对角线。正值表示上对角线,负值表示下对角线。
- **dtype** (Union[mindspore.dtype, str], 可选) - 指定的Tensor ``dtype`` 。默认值: ``mstype.float32``
返回:
Tensorshape为(N, M)。其中,除第 ``k`` 个对角线值等于1外其余所有元素都等于0。
异常:
- **TypeError** - 如果输入参数非给定的数据类型。