Multilayer Perceptrons

Dive into Deep Learning · §4

Multilayer Perceptrons: Breaking the Linear Barrier
hidden layers · backpropagation · variance-preserving initialization · generalization · dropout · Kaggle

Why Linear Classifiers Hit a Ceiling on Real Tasks

The Central Problem

  • No feature interactions (XOR): Flipping input bit x_1 in exclusive-OR reverses the output depending on x_2; no single hyperplane can separate all four corners of \{0, 1\}^2.
  • Context-blind pixel weights: In Fashion-MNIST, a bright pixel contributes the exact same vote toward a class whether its neighbors form a collar, a sleeve, or a handbag strap, capping linear accuracy at \sim 84\%.
  • The deep-learning solution: Insert hidden layers \mathbf{H} = \phi(\mathbf{X}\mathbf{W}^{(1)} + \mathbf{b}^{(1)}) that learn nonlinear feature combinations jointly with the output classifier (\sim 87\% accuracy).

Three Fundamental Challenges of Deep Networks

What Depth Introduces

  1. Efficient gradient computation: Finite differences would require 203{,}530 forward passes per step; backpropagation computes every gradient in one reverse sweep by caching forward activations in GPU RAM.
  2. Numerical stability across depth: Across K layers, signals and gradients pass through a product of K weight and slope matrices, requiring variance-preserving Xavier and He initialization.
  3. Generalization past interpolation: Overparameterized MLPs can memorize random noise yet generalize on real data via SGD’s implicit bias, early stopping, and dropout.

Running Benchmark: Fashion-MNIST Across the Chapter

Running Example

  • Softmax baseline (784 \to 10): 7{,}850 parameters (0.8\textrm{ MB} activations at n = 256) plateau at \sim 84\% validation accuracy.
  • 1- and 2-hidden-layer ReLU MLPs: Expand to 203{,}530–269{,}322 parameters and reach \sim 87\% accuracy at nearly the exact same GPU wall-clock time per epoch.
  • 10-layer depth test (795{,}658 params): Stays frozen at 10\% chance under \mathcal{N}(0, 0.01^2) initialization, but trains cleanly to 85\text{--}87\% under He initialization (\tau = \sqrt{2/n_{\textrm{in}}}).

Architectural & Mathematical Roadmap of the Chapter

Chapter Roadmap

  • Representation & features: Nonlinear activations prevent linear collapse, fold space into 2^m pieces with depth, and learn contrast patterns in place of whole-garment templates.
  • Optimization & stability: Three local VJP rules (\mathbf{X}^\top\mathbf{G}, \mathbf{G}\mathbf{W}^\top, \odot\,\phi') run in \sim 2\times forward FLOPs; setting h\tau^2\mathbb{E}[\phi'(z)^2] = 1 prevents vanishing/exploding products.
  • Generalization & tabular ML: Double descent, minimum-norm implicit bias, inverted dropout h' = \xi h / (1 - p), and leakage-free 5-fold Kaggle cross-validation.

Concept Check & Study Guide for the Chapter

Check & Synthesis

Before diving into the first section, test your intuition on two foundational questions that connect the sections ahead:

  1. Linear collapse: If we stack 10 fully connected layers of width 256 without activation functions (\phi(z) = z), does the network have more expressive power than a single 784 \times 10 linear layer?
  2. Memory vs. parameters: When training a deep network on minibatches of size n = 256, why can activation memory easily exceed parameter memory even when every hidden layer is narrower than the input?

Answers:

  1. No: (\mathbf{X}\mathbf{W}^{(1)})\mathbf{W}^{(2)}\cdots\mathbf{W}^{(10)} multiplies out to a single matrix \mathbf{X}\mathbf{W} of rank at most 256 (and at most 10 at the output). Nonlinear activations are essential to prevent algebraic collapse.
  2. Batch scaling: A weight matrix \mathbf{W}^{(k)} \in \mathbb{R}^{h \times h} stores h^2 floats independent of batch size, whereas its cached forward activation \mathbf{H}^{(k)} \in \mathbb{R}^{n \times h} stores nh floats per layer, growing linearly with both batch size n and depth K.