沿张量的轴查找唯一元素。
用法
tf.raw_ops.UniqueV2(
x, axis, out_idx=tf.dtypes.int32, name=None
)参数
-
x一个Tensor。一个Tensor。 -
axis一个Tensor。必须是以下类型之一:int32,int64。int32类型的Tensor(默认值:无)。用于查找唯一元素的张量轴。 -
out_idx一个可选的tf.DType来自:tf.int32, tf.int64。默认为tf.int32。 -
name操作的名称(可选)。
返回
-
Tensor对象(y,idx)的元组。 -
y一个Tensor。具有与x相同的类型。 -
idxTensor类型为out_idx。
此操作返回一个张量 y,其中包含沿张量 axis 的唯一元素。返回的唯一元素的排序顺序与它们在 x 中的 axis 中出现的顺序相同。此操作还返回一个张量 idx,其大小与 x 中沿 axis 维度的元素数相同。它包含唯一输出 y 中的索引。换句话说,对于带有 `axis = None 的 1-D 张量 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]
对于 2-D 张量 x 和 axis = 0 :
# tensor 'x' is [[1, 0, 0],
# [1, 0, 0],
# [2, 0, 0]]
y, idx = unique(x, axis=0)
y ==> [[1, 0, 0],
[2, 0, 0]]
idx ==> [0, 0, 1]
对于 2-D 张量 x 和 axis = 1 :
# tensor 'x' is [[1, 0, 0],
# [1, 0, 0],
# [2, 0, 0]]
y, idx = unique(x, axis=1)
y ==> [[1, 0],
[1, 0],
[2, 0]]
idx ==> [0, 1, 1]
相关用法
- Python tf.raw_ops.UniqueWithCounts用法及代码示例
- Python tf.raw_ops.Unique用法及代码示例
- 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.UniqueV2。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
