使用单个值或切片对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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
