tensorflow函数tf.scatter_sub()

tf.scatter_sub()作用是:

将ref中特定位置的数分别进行减法运算。

示例如下:

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]

(多维用tf.scatter_nd_sub)

你可能感兴趣的:(tensorflow)