mindspore/docs/api/api_python/ops/mindspore.ops.func_gather.rst

27 lines
1.2 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.ops.gather
======================
.. py:function:: mindspore.ops.gather(input_params, input_indices, axis, batch_dims=0)
返回输入tensor在指定轴及指定索引上对应元素的切片。
下图展示了Gather常用的计算过程
.. image:: ../images/Gather.png
其中params代表输入 `input_params` indices代表要切片的索引 `input_indices`
.. note::
- input_indices的值必须在 `[0, input_params.shape[axis])` 范围内。CPU与GPU平台越界访问将会抛出异常Ascend平台越界访问的返回结果是未定义的。
- Ascend平台上input_params的数据类型不能是 `mindspore.bool <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html#mindspore.dtype>`_
- 返回tensor的shape为 :math:`input\_params.shape[:axis] + input\_indices.shape[batch\_dims:] + input\_params.shape[axis + 1:]`
参数:
- **input_params** (Tensor) - 输入tensor。
- **input_indices** (Tensor) - 指定索引。
- **axis** (Union(int, Tensor[int])) - 指定轴。
- **batch_dims** (int) - batch维的数量。默认 ``0``
返回:
Tensor