2.5K Star 8.4K Fork 4.7K

GVPMindSpore/mindspore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mindspore.ops.func_unique.rst 981 Bytes
一键复制 编辑 原始数据 按行查看 历史
luojianing 提交于 2023-03-09 20:48 . fix experimental API warning

mindspore.ops.unique

.. py:function:: mindspore.ops.unique(input)

    对输入Tensor中元素去重,并返回一个索引Tensor,包含输入Tensor中的元素在输出Tensor中的索引。

    `y` 与 `idx` 的shape通常会有差别,因为 `y` 会将元素去重,而 `idx` 的shape与 `input` 一致。
    若需要 `idx` 与 `y` 的shape相同,请参考 :class:`mindspore.ops.UniqueWithPad` 算子。

    .. warning::
        这是一个实验性API,后续可能修改或删除。

    参数:
        - **input** (Tensor) - 需要被去重的Tensor。shape: :math:`(N,*)` ,其中 :math:`*` 表示任意数量的附加维度。

    返回:
        Tuple, `(y, idx)` 。 `y` 是与 `input` 数据类型相同的Tensor,包含 `input` 中去重后的元素。 `idx` 为索引Tensor,包含 `input` 中的元素在 `y` 中的索引,与 `input` 的shape相同。

    异常:
        - **TypeError** - `input` 不是Tensor。
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore
r2.3.q1

搜索帮助