Weight Initialization
Deriving proper initialization schemes from variance propagation analysis: Xavier/Glorot for sigmoid/tanh, He/Kaiming for ReLU, orthogonal initialization, and the relationship between initialization and gradient flow stability.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- The Variance Propagation Problem
- Xavier/Glorot Initialization
- He/Kaiming Initialization for ReLU
- Variance in the Backward Pass
- Orthogonal Initialization
- Initialization for Residual Networks
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Derive the variance of layer outputs as a function of weights and inputs.
- Derive the Xavier condition for maintaining variance across layers.
- Derive the He correction for ReLU networks.
- Analyze backward-pass variance propagation.
- Explain orthogonal initialization and its spectral properties.
Notation
- — number of neurons in layer (fan-in to layer )
- — weight matrix at layer
- — activations at layer
- — variance of activations
- — variance of weight entries
Core Intuition
If weights are initialized too small, signals shrink exponentially through layers (vanishing activations). If too large, signals explode. Proper initialization maintains the variance of activations (forward pass) and gradients (backward pass) across all layers, ensuring stable training from the first iteration.
Weight Initialization
VanishingThe Variance Propagation Problem
Consider layer with linear pre-activation:
Assuming and are independent, zero-mean, and iid within each layer:
For the signal to neither explode nor vanish, we need:
Xavier/Glorot Initialization
For linear or tanh activations (where near zero):
Forward pass condition: .
Backward pass condition (maintaining gradient variance): .
Xavier compromise (averaging both constraints):
In practice:
- Uniform:
- Gaussian:
He/Kaiming Initialization for ReLU
ReLU sets half the activations to zero: (for zero-mean Gaussian ).
Derivation. For :
The variance halves at each ReLU. To compensate:
Setting :
This is He initialization (He et al., 2015). The factor of 2 compensates for ReLU zeroing half the distribution.
Variance in the Backward Pass
During backpropagation, gradients propagate as:
By the same variance analysis:
For gradient stability: , giving .
Combined: Xavier averages the forward () and backward () constraints.
Orthogonal Initialization
Idea: Initialize as a (scaled) orthogonal matrix.
Construction: Generate a random Gaussian matrix, compute its QR decomposition , and set .
Property: All singular values of equal the gain. This means:
- Forward pass: (exact norm preservation).
- Backward pass: (exact gradient norm preservation).
For gain : perfect isometry. Prevents both explosion and vanishing for linear networks of arbitrary depth.
Initialization for Residual Networks
In a ResNet with skip connections , the variance accumulates:
After blocks, variance grows linearly. Fixup initialization (Zhang et al., 2019) scales the residual branch by :
so total variance remains regardless of depth.
Common Pitfalls
Pitfall 1. Using Xavier initialization with ReLU networks. The factor-of-2 correction is essential; without it, activations decay as .
Pitfall 2. Initializing all weights to zero. All neurons compute the same function → gradients are identical → symmetry never breaks. Always use random initialization.
Pitfall 3. Forgetting bias initialization. Biases are typically initialized to zero. For ReLU, a small positive bias (e.g., 0.01) can help prevent initial dead neurons, but is not standard.
Summary
- Xavier: — for sigmoid/tanh.
- He: — for ReLU (compensates 50% zeroing).
- Orthogonal: exact norm preservation via — strongest guarantee for linear dynamics.
- Residual scaling: prevents variance growth in deep ResNets.
- Proper initialization ensures stable gradient flow from the very first training step.
Exercises
Exercise 1. Derive equation (2) from the assumptions of independence and zero-mean.
Exercise 2. Show that for .
Exercise 3. For a linear network of depth with Xavier initialization, compute .
Exercise 4. Prove that an orthogonal matrix preserves norms: .
Exercise 5. For a ResNet with blocks and residual variance per block, derive the total output variance and verify the scaling correction.