scatter_update needs Variable not constant tensor:
Applies sparse updates to a variable reference.
I guess you passed a constant tensor to scater_update
that caused throw an exception. Here is an example in eager-mode:
import tensorflow as tf
tf.enable_eager_execution()
data = tf.Variable([[2],
[3],
[4],
[5],
[6]])
cond = tf.where(tf.less(data, 5)) # update value less than 5
match_data = tf.gather_nd(data, cond)
square_data = tf.square(match_data) # square value less than 5
data = tf.scatter_nd_update(data, cond, square_data)
print(data)
# array([[ 4],
# [ 9],
# [16],
# [ 5],
# [ 6]], dtype=int32)>