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

18 lines
1.0 KiB
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.indices
=================================
.. py:function:: mindspore.numpy.indices(dimensions, dtype=mstype.int32, sparse=False)
返回一个表示网格索引的数组。
计算一个数组其中子数组包含仅沿相应轴变化的索引值01...。
参数:
- **dimensions** (Union[list(int), tuple]) - 网格的shape。
- **dtype** (mindspore.dtype, 可选) - 指定结果的数据类型。
- **sparse** (boolean, 可选) - 返回网格的稀疏表示而非密集表示,默认值: ``False``
返回:
Tensor或元素为Tensor的Tuple。如果 ``sparse````False`` ,则返回一个网格索引数组: ``grid.shape = (len(dimensions),) + tuple(dimensions)`` 。如果 ``sparse````True`` 则返回数组的Tuple其中 ``grid[i].shape = (1, ..., 1, dimensions[i], 1, ..., 1)`` ``dimensions[i]`` 位于第 ``i`` 个位置。
异常:
- **TypeError** - 如果输入的 ``dimensions`` 不是Tuple或List。