Hello everyone.
I would like to take the derivative of the output with respect to the input. People in other pages have suggested this:
torch.autograd.grad(output, input, retain_graph=True)[0]
However, I think this method is not very efficient: Many of the operations needed to take derivative wrt inputs have already been calculated during the training (going backward from output to the layer just before the input). So, if, after training, I run the code above, I’m basically repeating many operations. Is that right? Is there any way that I take the derivatives wrt inputs using the last update of the training?
Thank you very much in advance.