將稀疏的 updates 應用於給定的單個值或切片
用法
tf.raw_ops.ScatterNdUpdate(
ref, indices, updates, use_locking=True, name=None
)參數
-
ref一個可變的Tensor。一個可變張量。應該來自變量節點。 -
indices一個Tensor。必須是以下類型之一:int32、int64。張量。必須是以下類型之一:int32、int64。參考的索引張量。 -
updates一個Tensor。必須與ref具有相同的類型。張量。必須與 ref 具有相同的類型。要添加到 ref 的更新值的張量。 -
use_locking可選的bool。默認為True。一個可選的布爾值。默認為真。如果為 True,則分配將受鎖保護;否則行為是未定義的,但可能表現出較少的爭用。 -
name操作的名稱(可選)。
返回
-
一個可變的
Tensor。具有與ref相同的類型。
變量根據 indices 。
ref 是排名為 P 的 Tensor ,而 indices 是排名為 Q 的 Tensor 。
indices 必須是整數張量,包含 ref 的索引。它必須是形狀 其中 0 < K <= P 。
indices 的最內維(長度為 K )對應於沿 ref 的 K 第維的元素(如果是 K = P )或切片(如果是 K < P )的索引。
updates 是等級為 Q-1+P-K 的 Tensor,形狀:
例如,假設我們要將 4 個分散的元素更新為 rank-1 張量到 8 個元素。在 Python 中,該更新將如下所示:
ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])
indices = tf.constant([[4], [3], [1] ,[7]])
updates = tf.constant([9, 10, 11, 12])
update = tf.scatter_nd_update(ref, indices, updates)
with tf.Session() as sess:
print sess.run(update)
對 ref 的更新結果如下所示:
[1, 11, 3, 10, 9, 6, 7, 12]
有關如何更新切片的更多詳細信息,請參閱 tf.scatter_nd 。
另見 tf.scatter_update 和 tf.batch_scatter_update 。
相關用法
- Python tf.raw_ops.ScatterNdSub用法及代碼示例
- Python tf.raw_ops.ScatterNdNonAliasingAdd用法及代碼示例
- 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.ScatterNdUpdate。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
