Part IX — Deep Learning Regularization, Normalization & Training Dynamics · Chapter 1

Weight initialization (Xavier & He/Kaiming)

Hook

Before a network has learned anything at all, its very first forward pass depends on nothing but its starting weights. Can a network be broken before training even begins?

Intuition
scale = 0.05 — layer 6 RMS = 6.29e-6

This is a genuine 6-layer network — 8 inputs, 8 outputs per layer, fixed random weights — with every weight multiplied by one shared scale. Drag it small: the signal shrinks by roughly the same fraction every layer, and six layers of shrinking compounds into almost nothing left.

Formalize

Each layer's output is a sum of fan-in\text{fan-in} random-weighted terms. Averaged over random weights, that sum's typical size scales like fan-inscale\sqrt{\text{fan-in}}\cdot\text{scale} times the input's size. For the signal to stay roughly the same size layer after layer — neither shrinking nor growing — that factor needs to sit near 11:

scale1fan-in\text{scale} \approx \frac{1}{\sqrt{\text{fan-in}}}
  • scale — the multiplier applied to every randomly-drawn initial weight.
  • fan-in — the number of inputs feeding into a neuron or layer.
  1. Xavier/Glorot: scale by the layer's own size

    Pick the initial weight scale from the layer's own size, not a fixed constant, so six layers or sixty behave the same way at the start.

Play
scale = 1.00 — layer 6 RMS = 4.02e+2 (ideal ≈ 0.354)

The dashed lines mark a healthy band. Push the scale toward 1 and the curve rockets upward, doubling or more with every layer — the "exploding" failure mode. This chapter's dataset has fan-in 8, so 1/80.3541/\sqrt{8}\approx0.354 is the scale that keeps the curve inside the band the whole way across.

Worked example

With fan-in 88:

  1. Too small — scale 0.05

    About seven times smaller than ideal (0.050.05 vs. 0.354\approx0.354). Each layer's signal scales by roughly fan-inscale=8×0.050.141\sqrt{\text{fan-in}}\cdot\text{scale} = \sqrt8\times0.05\approx0.141 — a shrink, not a hold. Compounding that six times: 0.14160.0000080.141^6\approx0.000008, taking the RMS (short for Root Mean Square) activation from about 1.51.5 at the input to under 0.00010.0001 by layer 6 — a network that's already numerically dead before a single gradient step.

  2. Too large — scale 1.0

    Roughly three times too large (1.01.0 vs. 0.354\approx0.354). Each layer's signal now scales by 8×1.02.83\sqrt8\times1.0\approx2.83 — a growth factor well above 11. Compounding that six times: 2.8365142.83^6\approx514, pushing the same six layers up past 400400.

  3. Just right — the ideal scale ≈ 0.354

    Every one of the six layers stays within about 0.4×0.4\times to 2×2\times of the input's own size — no compounding in either direction.

Checkpoint

Find a scale that keeps layer 6’s activation between 0.3 and 3 — neither dead nor blown up.

scale = 0.05 — layer 6 RMS = 6.29e-6
Move the scale slider to try it
Summary
scale1fan-in\text{scale} \approx \frac{1}{\sqrt{\text{fan-in}}}

A network that starts too small can't produce a signal worth learning from; one that starts too large saturates its activations and produces gradients too extreme to use. Good initialization doesn't teach the network anything — it just makes sure the forward pass survives long enough for training to start. The next chapter asks the same question about gradients flowing backward through depth, where an almost identical failure mode has its own name.