I want to update a slice of a tensor with 3 dimensions. Following How to do slice assignment in Tensorflow I would do something like
import tensorflow as tf
with tf.Session() as sess:
init_val = tf.Variable(tf.zeros((2, 3, 3)))
indices = tf.constant([[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1]])
update = tf.scatter_nd_add(init_val, indices, tf.ones(4))
init = tf.global_variables_initializer()
sess.run(init)
print(sess.run(update))
This works, but since my actual problem is more complex I would like to generate the set of indices somehow automatically by defining the beginning and the size of the slice, such as if you would use tf.slice(...). Do you have any ideas? Thanks in advance!
I am using TensorFlow 1.12, which is currently the most recent release.