requires_grad
)backward()
).grad
)torch.nn
torch.nn.Module
Base Classtorch.nn
losses)torch.optim
)torch.utils.data.Dataset
torchvision.transforms
)torch.utils.data.DataLoader
backward()
)Was this section helpful?
Jul 19, 2025
Fixed an error in the backward() method section. Replaced an incorrect code example with an accurate one to correctly demonstrate the runtime error for non-scalar tensors and its proper resolution.
torch.autograd.backward()
.torch.autograd
(PyTorch Tutorial), PyTorch Developers, 2024 (PyTorch) - A code-focused guide to using autograd
, demonstrating the backward()
method in various scenarios and explaining its interaction with the computation graph.