3
$\begingroup$

I'm trying to assign a new Value to a TF-Array. Here's my Code:

import tensorflow as tf
x = tf.zeros(shape=[5],dtype=tf.float32)
x[1]=0

The error message:

'tensorflow.python.framework.ops.EagerTensor' object does not support item assignment

What am I doing wrong?

$\endgroup$
1
$\begingroup$

You can't do this in Tensorflow.

For reference see: https://github.com/tensorflow/tensorflow/issues/33131

$\endgroup$
0
$\begingroup$

In order to change the value of a TF-Array, you need to set it Variable:

x = tf.Variable(tf.zeros(shape=[5],dtype=tf.float32))
x[1]=0
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.