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

19 lines
843 B
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` 的部分视图,其相对于 `dim1``dim2` 的对角线元素作为维度附加在形状的末尾。
参数:
- **input** (Tensor) - 输入Tensor其维度至少为2。
- **offset** (int, 可选) - 对角线与主对角线的偏移。可以是正值或负值。默认值0。
- **dim1** (int, 可选) - 二维子数组的第一轴对角线应该从这里开始。默认值0。
- **dim2** (int, 可选) - 二维子数组的第二轴对角线应该从这里开始。默认值1。
返回:
Tensor如果Tensor是二维则返回值是一维数组。
异常:
- **ValueError** - 输入Tensor的维度少于2。