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

16 lines
744 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.diag
=================================
.. py:function:: mindspore.numpy.diag(v, k=0)
用于提取或构造对角线数组。
参数:
- **v** (Tensor) - 如果 ``v`` 是二维数组,则返回其第 ``k`` 个对角线的副本。如果 ``v`` 是一维数组,则返回一个 ``v`` 作为第 ``k`` 个对角线的二维数组。
- **k** (int, 可选) - 对角线的位置, :math:`k>0` 即为对主对角线上方, :math:`k<0` 即为主对角线下方。
返回:
Tensor返回该数组的对角线元素或者构造一个新的二维数组其中指定的一维数组为对角线元素。
异常:
- **ValueError** - 如果 ``v`` 不是一维或者二维数组。