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

20 lines
955 B
ReStructuredText
Raw 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.Unique
====================
.. py:class:: mindspore.ops.Unique
返回输入Tensor的唯一元素以及其对应的每个值的索引。
输出包含Tensor `y` 和Tensor `idx` ,格式形如( `y` , `idx` )。Tensor `y` 和Tensor `idx` 的shape在大多数情况下是不同的因为Tensor `y` 可能存在重复并且Tensor `idx` 的shape与输入保持一致。
要获得 `idx``y` 之间相同的shape请参考 :class:`mindspore.ops.UniqueWithPad`
输入:
- **input_x** (Tensor) - 输入Tensor。shape为 :math:`(N,*)` ,其中 :math:`*` 表示,任意数量的附加维度。
输出:
tuple形如( `y` , `idx` )的Tensor对象 `y``input_x` 的数据类型相同,记录的是 `input_x` 中的唯一元素。 `idx` 是一个Tensor记录的是输入 `input_x` 元素相对应的索引。
异常:
- **TypeError** - 如果 `input_x` 不是Tensor。