Gradients from two different GradientTape calls

Hello there! I am trying to retrieve the first gradient with respect to the data and then use that gradient to do some operations. Finally, I would like to train my model weights but when I run the second gradient tape it says “Gradient does not exist for variables output”.
What could be causing that error?

Thanks a lot for your solution!

@Rosendo Hello and welcome to the forum.
May I ask in which way you’re using the Multiple Tapes?

For two different set of gradients:

with tf.GradientTape() as tape0, tf.GradientTape() as tape1:

or for second order gradients:

with tf.GradientTape() as tape0:
  with tf.GradientTape() as tape1:

feel free to find more examples here: