Lesson 4.6core2 h 30 min

Initialization and normalization

Keeping every layer's signal at the right scale, forward and backward

A network is a product of many layers, and products are unforgiving: a per-layer scale factor of 0.7 becomes 10−810^{-8} after 50 layers. Initialization sets that factor at step zero; normalization layers keep it in range for the rest of training. These two ideas, plus residual connections, are what turned "deep" from a slur into a plan — they are why ResNets (5.3 Architectures: LeNet → AlexNet → VGG → Inception → ResNet → EfficientNet → ConvNeXt) go to 152 layers and why every transformer block carries a LayerNorm or RMSNorm (7.4 Inside the block: residuals, LayerNorm, FFN and embeddings).

You'll be able to

  • Derive the variance-preservation condition for a linear layer and obtain LeCun, Xavier/Glorot and He initialization
  • Write the BatchNorm forward pass for training and inference and explain where it fails
  • Contrast BatchNorm, LayerNorm, RMSNorm and GroupNorm and choose the right one for an architecture
  • Explain pre-norm vs post-norm placement and why residual connections keep gradients alive
  • Diagnose bad initialization from the initial loss and activation statistics

Key ideas

  1. All-equal initialization makes hidden units identical forever; weights must be random, biases may be zero.
  2. Var(z) = n_in·Var(w)·Var(x): preserving scale needs Var(w) = 1/n_in (LeCun), 2/(n_in+n_out) (Xavier, for tanh/sigmoid) or 2/n_in (He, for ReLU).
  3. BatchNorm standardizes each feature over the batch, then rescales with γ, β; at inference it uses running statistics — remember model.eval().
Show 4 more key ideas
  1. BatchNorm helps by smoothing the loss landscape (higher LR, less init sensitivity), not by removing 'covariate shift'; it fails for small batches and sequences.
  2. LayerNorm normalizes each example across its features (no batch dependence); RMSNorm drops the centering and is the LLM default; GroupNorm serves small-batch vision.
  3. Pre-norm (x + Sub(LN(x))) leaves the residual stream unnormalized and trains stably; post-norm needs warmup and is fragile when deep.
  4. Residual connections give an identity term in the Jacobian product, so gradients always have an undiminished path to early layers.

Suggested path through this lesson