Skip to content
RED SAG Skills
hardStudy question · answer published in PyTorch interview questions, so no pointsdeep-learningpytorchautograd

Why .grad is None for an intermediate

After backward(), w.grad has values but h.grad is None. Why?

w = torch.randn(3, requires_grad=True)
h = w * 2
loss = (h ** 2).sum()
loss.backward()
print(w.grad, h.grad)
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions