mindspore/docs/api/api_python/numpy/mindspore.numpy.diag_indice...

17 lines
804 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_indices
=================================
.. py:function:: mindspore.numpy.diag_indices(n, ndim=2)
返回一个可以访问数组的主对角线的索引数组。
该函数返回一个索引的元组索引指向数组a的主对角线数组a满足 ``a.ndim >= 2`` 与shape为 `(n, n, …, n)` 。如果满足 ``a.ndim = 2`` 该接口与diagonal功能一致如果 ``a.ndim > 2`` ,则返回访问 ``a[i, i, ..., i]`` 的索引集合,其中 ``i = [0..n-1]``
参数:
- **n** (int) - 可使用返回索引的数组沿每个维度的大小。
- **ndim** (int, 可选) - 维数。
返回:
元素为Tensor的Tuple。
异常:
- **TypeError** - 如果没有按照上述内容给定的数据类型输入参数。