0
votes

I'm trying to create a for loop function as part of a convolutional neural network code to modify a variable if this variable is in a certain location of a 60 by 60 image. how can I do this in Tensorflow/Keras?

I always get this error: TypeError: 'Tensor' object does not support item assignment

def newvar(x):
    p = K.expand_dims(x[:, :, :, 1], -1)
    q= p*0.0
    for i in range(60):
        for j in range(60):
            if[i,j] in y.tolist()
               q[:,i,j,:] = (p[:, i, j, :]- (10 * p[:,i, j,:]))
    return q
1

1 Answers

0
votes

TensorFlow does not support item assignment for now... Try numpy first, then convert it to tf.float32.