How can we replace a single element in an n-D Tensor in TensorFlow? -
if have 1-d tensor, can replace single element 0-d tensor using tf.scatter_update or unpacking, replacing, packing.
example:
# pretend x came somewhere useful. x = tf.variable(0) = tf.variable([1, 2, 3]) # replace 2 whatever's in x = tf.scatter_update(a, 1, x) a produce [1, 0, 3].
is possible n-d arrays?
example:
# pretend x came somewhere useful. x = tf.variable(0, dtype=tf.float32) = tf.variable(np.random.rand(3, 3, 3, 3)) # what's equivalent of a[1, 1, 1, 1] = x ? i think desired result mixture of tf.unpack, tf.scatter_update, , tf.pack, it'd verbose, , we'd replacing (potentially large) 3-d tensor instead of replacing tiny 0-d tensor. there better way?
if want efficiently, believe need write new op or generalize scatter_update.
Comments
Post a Comment