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:

InitializationTypical useVariance scale
Xavier / Glorottanh, sigmoid, balanced forward/backward flow
Kaiming / HeReLU-family activations
orthogonalrecurrent or deep linear-like blockspreserves norm under assumptions
small final layerresidual adapters, output headsstarts near identity/no-op
zero biascommon defaultavoids 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.

ComponentInitialization concern
embedding tablescale affects early logits and representation norm
attention projectionsquery/key scale affects softmax sharpness
gate biascontrols initially open/closed memory path
residual branchshould not overwhelm skip path at start
output headaffects 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?