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

16 lines
603 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.identity
=================================
.. py:function:: mindspore.numpy.identity(n, dtype=mstype.float32)
返回单位数组。主对角线上全为1。
参数:
- **n** (int) - 设置的输出数组的行数和列数必须大于0。
- **dtype** (Union[mindspore.dtype, str], 可选) - 指定的Tensor ``dtype`` ,默认值: ``mstype.float32``
返回:
Tensorshape为 ``(n, n)`` 除主对角线上值为1其余所有元素都等于0。
异常:
- **TypeError** - 如果输入参数非上述给定的类型。