I'm looking for an "update" function that takes in a tensor t1
, some indices and values and returns a new tensor t2
, which is t1
but with the values at the indices changed accordingly.
This seems like the most basic of functions, but I do not see it in the documentation.
What I do see is tf.scatter_update
, which updates values in a Variable
: in a way it is what I want. I could conceivably construct a Variable
for t2
(would this work?), but t2
is not supposed to be a stateful variable and I would be populating it with arbitrary initial values.
Or, I could manually construct a Python nested list adding each element of t1
and t2
individually, then calling tf.convert_to_tensor
. I could be wrong, but this seems likely to horribly inefficient.
You can try tf.scatter_update or tf.scatter_add
to update tensor value according to indices.
See the question adjust-single-value-within-tensor-tensorflow for a reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With