mindspore/docs/api/api_python/ops/mindspore.ops.func_eye.rst

22 lines
1.2 KiB
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.ops.eye
==================
.. py:function:: mindspore.ops.eye(n, m=None, dtype=None)
创建一个主对角线上元素为1其余元素为0的Tensor。
.. note::
结合ReverseV2算子可以得到一个反对角线为1的Tensor但是目前ReverseV2算子只支持Ascend和GPU平台。
参数:
- **n** (int) - 指定返回Tensor的行数。仅支持常量值。
- **m** (int) - 指定返回Tensor的列数。仅支持常量值。默认值为None返回Tensor的列数默认与n相等。
- **dtype** (mindspore.dtype) - 指定返回Tensor的数据类型。数据类型必须是 `bool_ <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html#mindspore.dtype>`_`number <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html#mindspore.dtype>`_ 。默认值为None返回Tensor的数据类型默认为mindspore.float32。
返回:
Tensor主对角线上为1其余的元素为0。它的shape由 `n``m` 指定。数据类型由 `dtype` 指定。
异常:
- **TypeError** - `m``n` 不是int。
- **ValueError** - `m``n` 小于1。