Slice assignment to tensorflow variable
问题 I am trying to assign values to slice of a variable in tensorflow, but the following error is shown: 'ValueError: Sliced assignment is only supported for variables'. Why is this error showing even though I am trying to do slice assignment to a variable. My code is something like this: var1 = var1[startx:endx,starty:endy].assign(tf.ones([endx-startx,endy-starty],dtype=tf.int32)) where var1 is a tensorflow variable. 回答1: The other answer is correct; doing any operation to a tf variable does not