Unit 1 of 8 · about 5 hours · derive, measure

Initialization and signal scale across depth

Every later unit assumes signals survive the forward and backward pass. Wrong scale fails silently as flat or exploding loss, and no optimizer setting repairs it.

You'll be able to

  • Derive the He variance for ReLU layers from variance propagation, and state the Xavier form for symmetric activations.
  • Predict whether activations and gradients shrink or grow across depth for a stated initialization scale.
  • Measure per-layer activation and gradient norms in a deep MLP and name the failing regime.

Covers

Xavier and Kaiming initializationActivation and gradient scale across depth
1

Read

In this order, only the parts listed

0 of 3 done

  1. Parameter initialization (derivation)Understanding Deep Learning - fitting, gradients and regularization

    Chapter 7, Section 7.5 through 7.5.3 (pp. 107 to 111): forward variance, backward variance and the compromise

  2. Numerical stability, symmetry breaking and XavierD2L - optimization and regularization slice

    Vanishing and Exploding Gradients, Breaking the Symmetry, Parameter Initialization and Xavier Initialization; Summary

  3. HOML: Glorot and He initialization in PyTorchHands-On Machine Learning with Scikit-Learn and PyTorch

    Chapter 11, Glorot Initialization and He Initialization (printed pp. 365-368): Equation 11-1, Table 11-1 and the nn.init calls with model.apply

    Read it for the PyTorch default: nn.Linear draws Kaiming-uniform weights with bound , a factor below the He bound , so a ReLU stack needs nn.init.kaiming_uniform_ or kaiming_normal_ to reach the He scale.

2

Focus on

  • ReLU keeps about half of symmetric inputs, so is half the pre-activation variance. That half is where the factor 2 in He comes from.
  • Xavier balances fan-in against fan-out for the near-linear regime. UDL's compromise averages the two He conditions; it is not the classic tanh Xavier formula.
  • Constant initialization never breaks symmetry: identical weights give identical gradients, so units update identically forever. Randomness must differ across units, not just across layers.
  • Variance preservation is an expectation over random draws. One unlucky draw still skews a narrow layer, so width matters alongside scale.
Common mistakes · 3
  • Using Xavier variance for ReLU layers. Without the factor 2 the forward variance halves each layer; use He for ReLU and Xavier-style forms for tanh or sigmoid.
  • Reading UDL equation 7.34 as classic Xavier. It averages the forward and backward He conditions for ReLU, ; the chapter Notes (p. 113) say Glorot or Xavier initialization ignores the ReLU and so differs by a factor of two.
  • Concluding stability from one seed. Variance statements are expectations, so rerun narrow layers with fresh draws before trusting a scale.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive for a ReLU layer from mean-zero pre-activations and . Then push a batch through a 50-layer, width-100 ReLU MLP at weight variances 0.001, 0.02 and 1.0 and log the mean squared pre-activation per layer. Expect 0.001 to collapse toward zero, 1.0 to overflow, and 0.02 (the He value) to stay within about an order of magnitude of its start; single draws drift, so try a few seeds.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.A ReLU layer has fan-in 200. What weight variance preserves activation scale, and why 2 and not 1?Answer

    2/200 = 0.01. The ReLU clips about half of symmetric pre-activations to zero, halving ; the 2 compensates that half.

  2. 2.Tanh layer, fan-in 256, fan-out 128. Give the D2L Xavier uniform bound.Answer

    Uniform , since 6/(256+128) = 1/64.

  3. 3.All weights in an MLP layer are initialized to the same constant. What happens?Answer

    Every unit computes the same forward value and receives the same gradient, so they update identically forever. Symmetry never breaks; use independent random draws.

  4. 4.Init variance is far too large. Which two signatures do you expect forward and backward?Answer

    Pre-activation magnitudes grow with depth until floating point saturates, and gradient norms grow backward through the same products. Both come from multiplying by large weights at every layer.

5

Practice

  • D2L Numerical Stability and Initialization: Exercises

    Exercises: the symmetry-breaking, constant-init and eigenvalue questions

  • TrenTorch: Weight Initialization

    Implement xavier_uniform_bound, xavier_normal_std, kaiming_uniform_bound and kaiming_normal_std from the variance targets

    Derive each value before coding: Kaiming normal std with the default gain is , and each uniform bound is times its normal std because has variance .

You're done when

You derive without notes, and your probe shows collapse below the He value, overflow above it, and bounded drift at it across a few seeds.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 9 more in the section
  • Understanding Deep Learning - fitting, gradients and regularizationSimon J. D. Prince · primary

    Use Chapters 6-9 and targeted parts of Chapter 20 for optimization, initialization, measurement, regularization and why training works. Re-derive the update rules you keep in the trainer.

  • D2L - optimization and regularization sliceD2L authors · required

    Use MLP implementation, dropout, deep generalization, numerical stability, optimization introduction, SGD, minibatch SGD, momentum, AdaGrad, RMSProp, Adam and learning-rate scheduler. Implement momentum, AdamW, initialization, dropout, one normalization, clipping and one schedule.

  • Hands-On Machine Learning with Scikit-Learn and PyTorchAurelien Geron (O'Reilly, 2025) · support

    Read the Chapter 11 sections named in the units for the PyTorch side of initialization, normalization, clipping and schedules.

Also in this section