I don't understand pytorch grad can anyone explain
x = torch.tensor(6.0, requires_grad=True) f = x ** 2 f f.backward(retain_graph=True) x.grad I am learning pytorch and I encounter this code above when i run it i got 36.0(the value of f) but after doing f.backward() and then x.grad i got 12 i don't understand why can anyone explain this to me submi…
Read the full story at r/learnmachinelearning ↗
Timeline · 1 report
- 2026-09-19 05:53 · r/learnmachinelearning
I don't understand pytorch grad can anyone explain