类似的 sub函数!
ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8],dtype = tf.int32)
indices = tf.constant([4, 3, 1, 7],dtype = tf.int32)
updates = tf.constant([9, 10, 11, 12],dtype = tf.int32)
sub = tf.scatter_sub(ref, indices, updates)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print sess.run(sub)
[ 1 -9 3 -6 -4 6 7 -4] 结果,indices 4,对应ref中的5,updates中的是9, 5-9= -4,因此ref的第4个位置-4,其他位置类似