mindspore/docs/api/api_python/ops/mindspore.ops.func_diagonal...

19 lines
1.1 KiB
ReStructuredText
Raw 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.diagonal
=======================
.. py:function:: mindspore.ops.diagonal(input, offset=0, dim1=0, dim2=1)
返回 `input` 特定的对角线视图。如果 `input` 为2-D返回偏移量为 `offset` 的对角线元素。如果 `input` 维度大于2则返回由 `dim1``dim2` 确定的2-D子数组的对角线视图。其相对于 `dim1``dim2` 的对角线元素作为维度附加在形状的末尾。
参数:
- **input** (Tensor) - 输入Tensor其维度至少为2。
- **offset** (int, 可选) - 对角线与主对角线的偏移。可以是正值或负值。默认值0。
- **dim1** (int, 可选) - 二维子数组的第一轴对角线应该从这里开始。默认值0。
- **dim2** (int, 可选) - 二维子数组的第二轴对角线应该从这里开始。默认值1。
返回:
Tensor如果Tensor是二维则返回值是一维数组如果输入维度大于2则先移除维度 `dim1``dim2` 然后在末尾插入新的一维来对应对角元素。
异常:
- **ValueError** - 输入Tensor的维度少于2。