将稀疏的 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
