Dive into Deep Learning · §3
Linear Neural Networks for Classification: From Logits to Trusted Decisions
one-hot labels · softmax · cross-entropy · Fashion-MNIST · calibration · generalization · distribution shift
The Central Challenge
Predicting an unordered discrete category (y \in \{1, \ldots, q\}) departs from continuous regression in three fundamental ways:
The Modelling Recipe
Our regression training pipeline—minibatch loaders, vectorized GEMM, autodiff, and SGD—carries over with three targeted upgrades:
Chapter Roadmap
The six sections progress from mathematical formulation and benchmark data to implementation, decision metrics, statistical guarantees, and deployment robustness:
DataModule (60\text{k} + 10\text{k} garments), Classifier base class, 10\times 10 confusion matrices, and fused LogSumExp loss.Empirical Anchors
Every concept in this chapter is anchored to concrete numbers and reproducible experiments:
Self-Assessment
Before diving into §3.1, test your intuition on three foundational questions that motivate the chapter:
float32), why does evaluating \exp(1000) / (\exp(1000) + \exp(0) + \exp(0)) return NaN even though the mathematical ratio is 1?Answers: (1) Each of the q = 10 classes needs its own 784-pixel weight vector \mathbf{w}_j and bias b_j to score class j against all others (784 \times 10 + 10 = 7{,}850). (2) float32 overflows to inf around \exp(88.7) \approx 3.4 \times 10^{38}, turning the ratio into \infty / \infty = \texttt{NaN}; subtracting \max_k o_k = 1000 first keeps all exponents \le 0. (3) No: at \epsilon = 0.17 and n = 10{,}000, a single model’s standard error is \sqrt{0.17 \times 0.83 / 10{,}000} \approx 0.38 percentage points (95\% radius \pm 0.74 points).