使用單個值或切片對input 應用稀疏加法
用法
tf.raw_ops.ScatterNdNonAliasingAdd(
input, indices, updates, name=None
)參數
-
inputATensor.必須是以下類型之一:float32,float64,int32,uint8,int16,int8,complex64,int64,qint8,quint8,qint32,bfloat16,uint16,complex128,half,uint32,uint64,bool.張量。 -
indices一個Tensor。必須是以下類型之一:int32、int64。張量。必須是以下類型之一:int32、int64。input的索引張量。 -
updates一個Tensor。必須與input具有相同的類型。張量。必須與 ref 具有相同的類型。要添加到input的更新值的張量。 -
name操作的名稱(可選)。
返回
-
一個
Tensor。具有與input相同的類型。
從 updates 根據索引 indices 。更新是非混疊的:input 僅在沒有其他操作將使用它的情況下就地修改。否則,將製作input 的副本。此操作相對於 input 和 updates 都有梯度。
input 是排名為 P 的 Tensor ,而 indices 是排名為 Q 的 Tensor 。
indices 必須是整數張量,包含 input 的索引。它必須是形狀 其中 0 < K <= P 。
indices 的最裏麵的維度(長度為 K )對應於沿 K 的 input 的第 K 維度的元素索引(如果是 K = P )或 (P-K) 維切片(如果是 K < P )。
updates 是等級為 Q-1+P-K 的 Tensor,形狀:
例如,假設我們要將 4 個分散的元素添加到 rank-1 張量到 8 個元素。在 Python 中,該添加看起來像這樣:
input = tf.constant([1, 2, 3, 4, 5, 6, 7, 8])
indices = tf.constant([[4], [3], [1], [7]])
updates = tf.constant([9, 10, 11, 12])
output = tf.scatter_nd_non_aliasing_add(input, indices, updates)
with tf.Session() as sess:
print(sess.run(output))
結果值 output 如下所示:
[1, 13, 3, 14, 14, 6, 7, 20]
有關如何更新切片的更多詳細信息,請參閱 tf.scatter_nd 。
相關用法
- Python tf.raw_ops.ScatterNdUpdate用法及代碼示例
- Python tf.raw_ops.ScatterNdSub用法及代碼示例
- Python tf.raw_ops.ScatterNdAdd用法及代碼示例
- Python tf.raw_ops.ScatterNd用法及代碼示例
- Python tf.raw_ops.ScatterUpdate用法及代碼示例
- Python tf.raw_ops.ScatterAdd用法及代碼示例
- Python tf.raw_ops.ScatterSub用法及代碼示例
- Python tf.raw_ops.ScatterDiv用法及代碼示例
- Python tf.raw_ops.ScatterMul用法及代碼示例
- Python tf.raw_ops.ScatterMin用法及代碼示例
- Python tf.raw_ops.ScatterMax用法及代碼示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代碼示例
- Python tf.raw_ops.SegmentMean用法及代碼示例
- Python tf.raw_ops.Size用法及代碼示例
- Python tf.raw_ops.SparseCrossV2用法及代碼示例
- Python tf.raw_ops.Sub用法及代碼示例
- Python tf.raw_ops.SparseCross用法及代碼示例
- Python tf.raw_ops.Svd用法及代碼示例
- Python tf.raw_ops.StringStrip用法及代碼示例
- Python tf.raw_ops.SparseConcat用法及代碼示例
- Python tf.raw_ops.SparseSegmentSumWithNumSegments用法及代碼示例
- Python tf.raw_ops.SparseMatrixSparseMatMul用法及代碼示例
- Python tf.raw_ops.SparseMatrixOrderingAMD用法及代碼示例
- Python tf.raw_ops.Shape用法及代碼示例
- Python tf.raw_ops.Sign用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.raw_ops.ScatterNdNonAliasingAdd。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
