查找一维张量中的唯一元素。
用法
tf.raw_ops.Unique(
x, out_idx=tf.dtypes.int32, name=None
)参数
返回
-
Tensor对象(y,idx)的元组。 -
y一个Tensor。具有与x相同的类型。 -
idxTensor类型为out_idx。
此操作返回一个张量 y ,其中包含 x 的所有唯一元素,这些元素的排序顺序与它们在 x 中出现的顺序相同; x 不需要排序。此操作还返回一个与 x 大小相同的张量 idx,其中包含唯一输出 y 中每个 x 值的索引。换一种说法:
y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]
例子:
# tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx = unique(x)
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]# tensor 'x' is [4, 5, 1, 2, 3, 3, 4, 5]
y, idx = unique(x)
y ==> [4, 5, 1, 2, 3]
idx ==> [0, 1, 2, 3, 4, 4, 0, 1]
相关用法
- Python tf.raw_ops.UniqueWithCounts用法及代码示例
- Python tf.raw_ops.UniqueV2用法及代码示例
- Python tf.raw_ops.UniqueWithCountsV2用法及代码示例
- Python tf.raw_ops.UnicodeScript用法及代码示例
- Python tf.raw_ops.UnicodeTranscode用法及代码示例
- Python tf.raw_ops.UnicodeEncode用法及代码示例
- Python tf.raw_ops.UnsortedSegmentProd用法及代码示例
- Python tf.raw_ops.UnsortedSegmentJoin用法及代码示例
- Python tf.raw_ops.UnsortedSegmentSum用法及代码示例
- Python tf.raw_ops.UnravelIndex用法及代码示例
- Python tf.raw_ops.UnsortedSegmentMin用法及代码示例
- Python tf.raw_ops.UnsortedSegmentMax用法及代码示例
- Python tf.raw_ops.TPUReplicatedInput用法及代码示例
- Python tf.raw_ops.Bitcast用法及代码示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代码示例
- Python tf.raw_ops.BatchMatMul用法及代码示例
- Python tf.raw_ops.OneHot用法及代码示例
- Python tf.raw_ops.ResourceScatterNdSub用法及代码示例
- Python tf.raw_ops.ReadVariableXlaSplitND用法及代码示例
- Python tf.raw_ops.GatherV2用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.raw_ops.Unique。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
