Define nn.Module
layers + forward()
Forward pass
compute predictions
Compute loss
cross-entropy
Backward pass
autograd computes gradients
Optimizer step
update weights
PyTorch's nn.Module gives you parameter tracking, device movement, and serialization for free. Let's build a small MLP for digit classification and train it end to end.