查找一維張量中的唯一元素。
用法
tf.raw_ops.UniqueWithCounts(
x, out_idx=tf.dtypes.int32, name=None
)參數
返回
-
Tensor對象的元組(y、idx、count)。 -
y一個Tensor。具有與x相同的類型。 -
idxTensor類型為out_idx。 -
countTensor類型為out_idx。
此操作返回一個張量 y ,其中包含 x 的所有唯一元素,這些元素的排序順序與它們在 x 中出現的順序相同。此操作還返回一個與 x 大小相同的張量 idx,其中包含唯一輸出 y 中每個 x 值的索引。最後,它返回第三個張量 count,其中包含 x 中 y 的每個元素的計數。換一種說法:
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, count = unique_with_counts(x)
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]
count ==> [2, 1, 3, 1, 2]
相關用法
- Python tf.raw_ops.UniqueWithCountsV2用法及代碼示例
- Python tf.raw_ops.UniqueV2用法及代碼示例
- Python tf.raw_ops.Unique用法及代碼示例
- 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.UniqueWithCounts。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
