Study
Deep Learning · PyTorch training loop
The standard PyTorch loop with Dataset, DataLoader, nn.Module, a loss, an optimiser and an evaluation pass, applied to scikit-learn's handwritten digits.
- Every PyTorch training step is the same five lines: zero_grad, forward, loss, backward, step.
- Switch between model.train() and model.eval() so dropout and batch norm behave correctly.