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

22 lines
958 B
ReStructuredText
Raw Permalink Normal View History

2022-05-29 11:14:01 +08:00
mindspore.ops.unique
====================
2022-06-16 16:03:13 +08:00
.. py:function:: mindspore.ops.unique(x)
2022-05-29 11:14:01 +08:00
对输入Tensor中元素去重并返回一个索引Tensor包含输入Tensor中的元素在输出Tensor中的索引。
`y``idx` 的shape通常会有差别因为 `y` 会将元素去重,而 `idx` 的shape与 `x` 一致。
若需要 `idx``y` 的shape相同请参考 :class:`mindspore.ops.UniqueWithPad` 算子。
.. warning::
此算子为实验性算子,将来可能面临更改或删除。
2022-07-26 10:27:56 +08:00
参数:
- **x** (Tensor) - 需要被去重的Tensor。shape :math:`(N,*)` ,其中 :math:`*` 表示任意数量的附加维度。
2022-05-29 11:14:01 +08:00
2022-07-26 10:27:56 +08:00
返回:
Tuple `(y, idx)``y` 是与 `x` 数据类型相同的Tensor包含 `x` 中去重后的元素。 `idx` 为索引Tensor包含 `x` 中的元素在 `y` 中的索引,与 `x` 的shape相同。
2022-05-29 11:14:01 +08:00
2022-07-26 10:27:56 +08:00
异常:
- **TypeError** - `x` 不是Tensor。