沿張量的軸查找唯一元素。
用法
tf.raw_ops.UniqueWithCountsV2(
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、count)。 -
y一個Tensor。具有與x相同的類型。 -
idxTensor類型為out_idx。 -
countTensor類型為out_idx。
此操作返回一個張量 y,其中包含沿張量 axis 的唯一元素。返回的唯一元素的排序順序與它們在 x 中的 axis 中出現的順序相同。此操作還返回一個張量 idx 和一個張量 count,它們的大小與 x 中沿 axis 維度的元素數量相同。 idx 包含唯一輸出 y 中的索引,而 count 包含唯一輸出 y 中的計數。換句話說,對於帶有 `axis = None 的 1-D 張量 x:
y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]
例如:
x = tf.constant([1, 1, 2, 4, 4, 4, 7, 8, 8])
y, idx, count = UniqueWithCountsV2(x, axis = [0])
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]
count ==> [2, 1, 3, 1, 2]
對於 2-D 張量 x 和 axis = 0 :
x = tf.constant([[1, 0, 0],
[1, 0, 0],
[2, 0, 0]])
y, idx, count = UniqueWithCountsV2(x, axis=[0])
y ==> [[1, 0, 0],
[2, 0, 0]]
idx ==> [0, 0, 1]
count ==> [2, 1]
對於 2-D 張量 x 和 axis = 1 :
x = tf.constant([[1, 0, 0],
[1, 0, 0],
[2, 0, 0]])
y, idx, count = UniqueWithCountsV2(x, axis=[1])
y ==> [[1, 0],
[1, 0],
[2, 0]]
idx ==> [0, 1, 1]
count ==> [1, 2]
相關用法
- Python tf.raw_ops.UniqueWithCounts用法及代碼示例
- 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.UniqueWithCountsV2。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
