mindspore/docs/api/api_python/mint/mindspore.mint.func_unique.rst

21 lines
1.3 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.mint.unique
=====================
.. py:function:: mindspore.mint.unique(input, sorted=True, return_inverse=False, return_counts=False, dim=None)
对输入tensor中元素去重。
参数:
- **input** (Tensor) - 输入tensor。
- **sorted** (bool可选) - 是否对返回值进行升序排序。默认 ``True``
- **return_inverse** (bool可选) - 是否额外返回一个tensor表示 `input``output` 上对应的index。默认 ``False``
- **return_counts** (bool可选) - 是否额外返回一个tensor表示输出 `output` 中的每个元素在 `input` 中的数量。默认 ``False``
- **dim** (int可选) - 指定计算维度。
返回:
一个tensor或者几个tensor的集合
- **output** (Tensor) - `input` 中去重后的元素。
- **inverse_indices** (Tensor) - 当 `return_inverse=True` 时返回,表示 `input` 中的每个元素在 `output` 上对应的位置索引。当 `dim=None`shape和 `input` 一样;当 `dim` 有值的时候shape是input.shape[dim]。
- **counts** (Tensor) - 当 `return_counts=True` 时返回,表示 `output` 中每个元素在 `input` 中的数量。当 `dim=None`shape和 `output` 一样;当 `dim` 有值的时候shape是output.shape[dim]。