Dive into Deep Learning · §2
Linear Neural Networks for Regression
affine models · squared loss · normal equations · minibatch SGD · generalization · weight decay
The Proving Ground
Architectural Roadmap
Module / DataModule / Trainer, and swap in the framework’s dense layers and optimizers.Quantitative Anchors
End-to-End Perspective
Every model in the rest of this book—from multilayer perceptrons to Transformers—reuses the exact pipeline we construct in this chapter:
Module): Map minibatch inputs \mathbf{X} \in \mathbb{R}^{|\mathcal{B}| \times d} to predictions \hat{\mathbf{y}} and evaluate the penalized empirical loss L_{\mathcal{B}}(\mathbf{w}, b) + \frac{\lambda}{2}\|\mathbf{w}\|_2^2.Trainer): Differentiate L_{\mathcal{B}} via reverse-mode autograd and step parameters via (\mathbf{w}, b) \leftarrow (\mathbf{w}, b) - \eta \nabla L_{\mathcal{B}}.DataModule): Track held-out risk after every epoch to tune hyperparameters (\eta, |\mathcal{B}|, \lambda) without leaking test data.Viewed as a neural network, linear regression is a single fully connected layer with d inputs and 1 linear output neuron.