查找最後一個維度的 k 最大元素的值和索引。
用法
tf.raw_ops.TopK(
input, k, sorted=True, name=None
)參數
-
input一個Tensor。必須是以下類型之一:float32,float64,int32,uint8,int16,int8,int64,bfloat16,uint16,half,uint32,uint64。一維或更高,最後一維至少k。 -
kint即>= 0。沿最後一個維度(沿矩陣的每一行)查找的頂部元素的數量。 -
sorted可選的bool。默認為True。如果為 true,則生成的k元素將按值降序排序。 -
name操作的名稱(可選)。
返回
-
Tensor對象(值、索引)的元組。 -
values一個Tensor。具有與input相同的類型。 -
indicesTensor類型為int32。
如果輸入是向量(rank-1),則在向量中找到 k 最大的條目,並將它們的值和索引作為向量輸出。因此 values[j] 是 j - input 中最大的條目,其索引是 indices[j] 。
對於矩陣(分別是更高等級的輸入),計算每行中的頂部 k 條目(分別是沿最後一個維度的向量)。因此,
values.shape = indices.shape = input.shape[:-1] + [k]
如果兩個元素相等,則首先出現lower-index 元素。
如果k 動態變化,請使用下麵的TopKV2。
相關用法
- Python tf.raw_ops.TopKV2用法及代碼示例
- Python tf.raw_ops.TPUReplicatedInput用法及代碼示例
- Python tf.raw_ops.TensorScatterMax用法及代碼示例
- Python tf.raw_ops.Tanh用法及代碼示例
- Python tf.raw_ops.TensorScatterSub用法及代碼示例
- Python tf.raw_ops.TensorArrayConcatV3用法及代碼示例
- Python tf.raw_ops.TakeManySparseFromTensorsMap用法及代碼示例
- Python tf.raw_ops.Tile用法及代碼示例
- Python tf.raw_ops.TPUReplicatedOutput用法及代碼示例
- Python tf.raw_ops.TensorScatterAdd用法及代碼示例
- Python tf.raw_ops.TensorArraySplitV3用法及代碼示例
- Python tf.raw_ops.Tan用法及代碼示例
- Python tf.raw_ops.TensorScatterUpdate用法及代碼示例
- 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.TopK。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
