then i get an error when trying to apply gradients with respect to the input

It works now. Thanks to @klapeyron. I updated tf.Variable values with values from input_tensor:

optimizer = tf.keras.optimizers.Adam(learning_rate=0.01)

initial_input = [tf.convert_to_tensor(latents), tf.convert_to_tensor(labels)]
input_tensor = tf.Variable([initial_input[0]])

for step in range(100):
    with tf.GradientTape() as tape:[0])

        initial_input[0] = input_tensor[0,:,:]
        generated_image = generator(initial_input)initial_input[1]])
        loss_value = mse_loss(generated_image, target_image)
    gradients = tape.gradient(loss_value, [initial_input[0]])
    optimizer.apply_gradients(zip([gradients], [input_tensor]))

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top