How do I change a single value of a Tensor inside of a while loop?
I know that I can manipulate a single value of a tf.Variable
using tf.scatter_update(variable, index, value)
, but inside of a loop I cannot access variables. Is there a way/workaround to manipulate a given value of a Tensor
inside of a while loop.
For reference, here is my current code:
my_variable = tf.Variable()
def body(i, my_variable):
[...]
return tf.add(i, 1), tf.scatter_update(my_variable, [index], value)
loop = tf.while_loop(lambda i, _: tf.less(i, 5), body, [0, my_variable])