Weight Initialization
Weight initialization sets model parameters before training. It controls early activation scale, gradient scale, symmetry breaking, and whether optimization starts in a stable regime.
A common goal is to keep activation variance roughly constant across layers:
If the variance grows or shrinks exponentially with depth, gradients can explode or vanish before the optimizer has a chance to learn.
For a linear layer
with independent weights and inputs, a rough variance propagation argument gives:
So keeping variance stable suggests:
The exact constant depends on activation function, fan-out, residual path, and normalization.
Xavier / Glorot Initialization
For tanh-like activations or balanced fan-in/fan-out layers:
is fan-in and is fan-out.
Kaiming / He Initialization
For ReLU-like activations, a common variance target is:
The factor accounts for the ReLU discarding roughly half the signal.
Fan-In and Fan-Out
For a dense matrix :
For convolution, fan-in and fan-out include kernel area:
| Initialization | Typical use | Variance scale |
|---|---|---|
| Xavier / Glorot | tanh, sigmoid, balanced forward/backward flow | |
| Kaiming / He | ReLU-family activations | |
| orthogonal | recurrent or deep linear-like blocks | preserves norm under assumptions |
| small final layer | residual adapters, output heads | starts near identity/no-op |
| zero bias | common default | avoids initial offset |
Residual and Normalized Networks
Residual networks change the initialization question because each block adds to an existing stream:
If is too large at initialization, the residual stream scale can grow with depth. Common stabilizers include smaller residual branch initialization, normalization placement, and zero-initialized final projections in residual blocks.
| Component | Initialization concern |
|---|---|
| embedding table | scale affects early logits and representation norm |
| attention projections | query/key scale affects softmax sharpness |
| gate bias | controls initially open/closed memory path |
| residual branch | should not overwhelm skip path at start |
| output head | affects initial loss scale and calibration |
Modern Notes
- Residual branches may need scaling in very deep networks.
- Normalization reduces but does not remove initialization sensitivity.
- Embeddings, output heads, gates, and attention projections may use different initialization rules.
- Zero or near-zero initialization can be useful for residual adapters or final projection layers, but dangerous if it prevents symmetry breaking.
Checks
- Is initialization matched to activation function and fan-in/fan-out?
- Are residual branches scaled deliberately?
- Are pretrained weights, random initialization, adapters, and task heads initialized differently?
- Does the run log the seed and model version?
- Does instability appear before data or optimizer effects can explain it?
- Are fan-in/fan-out computed correctly for convolution or grouped layers?
- Are gate biases and final projections initialized intentionally?