根據 indices 從 params 軸 axis 收集切片。
用法
tf.raw_ops.GatherV2(
params, indices, axis, batch_dims=0, name=None
)參數
-
params一個Tensor。從中收集值的張量。必須至少排名axis + 1。 -
indices一個Tensor。必須是以下類型之一:int32,int64。索引張量。必須在[0, params.shape[axis])範圍內。 -
axis一個Tensor。必須是以下類型之一:int32,int64。params中要從中收集indices的軸。默認為第一個維度。支持負索引。 -
batch_dims可選的int。默認為0。 -
name操作的名稱(可選)。
返回
-
一個
Tensor。具有與params相同的類型。
indices 必須是任意維度的整數張量(通常為 0-D 或 1-D)。生成形狀為 params.shape[:axis] +
indices.shape[batch_dims:] + params.shape[axis + 1:] 的輸出張量,其中:
# Scalar indices (output is rank(params) - 1).
output[a_0, ..., a_n, b_0, ..., b_n] =
params[a_0, ..., a_n, indices, b_0, ..., b_n]
# Vector indices (output is rank(params)).
output[a_0, ..., a_n, i, b_0, ..., b_n] =
params[a_0, ..., a_n, indices[i], b_0, ..., b_n]
# Higher rank indices (output is rank(params) + rank(indices) - 1).
output[a_0, ..., a_n, i, ..., j, b_0, ... b_n] =
params[a_0, ..., a_n, indices[i, ..., j], b_0, ..., b_n]
請注意,在 CPU 上,如果發現超出範圍的索引,則會返回錯誤。在 GPU 上,如果發現超出範圍的索引,則將 0 存儲在相應的輸出值中。
另請參見 tf.batch_gather 和 tf.gather_nd 。
相關用法
- Python tf.raw_ops.Gather用法及代碼示例
- Python tf.raw_ops.GatherNd用法及代碼示例
- Python tf.raw_ops.Greater用法及代碼示例
- Python tf.raw_ops.GreaterEqual用法及代碼示例
- Python tf.raw_ops.GRUBlockCellGrad用法及代碼示例
- Python tf.raw_ops.GenerateBoundingBoxProposals用法及代碼示例
- Python tf.raw_ops.GRUBlockCell用法及代碼示例
- 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.Expm1用法及代碼示例
- Python tf.raw_ops.BitwiseAnd用法及代碼示例
- Python tf.raw_ops.UniqueWithCounts用法及代碼示例
- Python tf.raw_ops.DecodeGif用法及代碼示例
- Python tf.raw_ops.Size用法及代碼示例
- Python tf.raw_ops.ScatterUpdate用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.raw_ops.GatherV2。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
