Pytorch gradient calculation - vision - PyTorch Forums
discuss.pytorch.org › t › pytorch-gradientJan 08, 2022 · Hi, I am new to pytorch and this is what I want to do: I have two models that are related to one another: modelA and modelB. I want to get three separate gradients. I am able to get the first two without any issues, but I am not sure how I can get the third one. differentiating the loss of modelA wrt modelA.parameters [v.grad.data for v in modelA.parameters()] differentiating the loss of ...