Hi.
That’s right. But how can I get dy/dx, in the training process? I mean, apply backward() on the loss function but somehow get dy/dx? Because going back thourgh the computation graph of a simple one layer NN, backpropagations calculates these:
dL/dy
dy/dH
dH/dW
. Right?
Since x.reauires_grad_() was applied, we also have dH/dx. So we should somehow get dy/dx=dy/dH * dH/dx, automatically, but I don’t know how to do this.
As I said before, I know the following code works, but I’m looking for something that doesn’t need to take all the gradients one more time after training is completed.
torch.autograd.grad(output, input, retain_graph=True)[0]

Thanks a lot.