tf.scatter_update can only be applied to the Variable type. data in your code IS a Variable , and data2 NOT, because the return type of tf.reshape is Tensor .
Decision:
for tensor flow after v1.0
data = tf.Variable([[1,2,3,4,5], [6,7,8,9,0], [1,2,3,4,5]]) row = tf.gather(data, 2) new_row = tf.concat([row[:2], tf.constant([0]), row[3:]], axis=0) sparse_update = tf.scatter_update(data, tf.constant(2), new_row)
for tensor flow before v1.0
data = tf.Variable([[1,2,3,4,5], [6,7,8,9,0], [1,2,3,4,5]]) row = tf.gather(data, 2) new_row = tf.concat(0, [row[:2], tf.constant([0]), row[3:]]) sparse_update = tf.scatter_update(data, tf.constant(2), new_row)