答案 0 :(得分:1)
tf.scatter_update专为此类用例而设计。这是代码示例:
import tensorflow as tf
list_index_false = tf.constant([5, 3])
list_boolean = tf.Variable(tf.fill([7], True))
list_boolean = tf.scatter_update(list_boolean, list_index_false, tf.fill(tf.shape(list_index_false), False))
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print(sess.run(list_boolean))
希望它有所帮助!