Weight Initialization › He Initialization for ReLU Networks
Language AI HandbookAll chapters Weight Initialization › He Initialization for ReLU NetworksOne section · Sections in this chapter7 / 19 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Xavier initialization was a breakthrough for networks with tanh or sigmoid activations. But by the mid-2010s, ReLU (Rectified Linear Unit) had become the dominant activation function due to its simplicity and its resistance to the vanishing gradient problem. Unfortunately, Xavier initialization performs poorly in ReLU networks.
The problem is fundamental. Xavier's derivation assumes the activation function is approximately linear near zero, so it does not systematically distort variance. Tanh and sigmoid satisfy this: near zero, both behave approximately like the identity function. ReLU does not. It zeros all negative inputs, keeping only the positive half of the distribution. This asymmetry means ReLU is far from linear around zero, and the linear approximation underlying Xavier's derivation breaks down completely.
The practical consequence is severe. A deep ReLU network initialized with Xavier will see its activations slowly collapse toward zero as the depth increases, because each ReLU layer systematically discards half the information by zeroing all negative values. The network can still learn, but it starts from a much worse position than necessary.
ReLU's Variance Halving Effect
Consider a pre-activation drawn from a symmetric distribution centered at zero with variance . ReLU applies , zeroing all negative values while keeping positive values unchanged. Since the distribution is symmetric around zero, approximately half the values are negative and become zero.
The variance of the ReLU output is:
where:
- : the rectified linear unit function that passes positive inputs and zeros negative ones
- : the variance of the input pre-activation before applying ReLU
- : the variance reduction factor, because ReLU eliminates roughly half the distribution (all values below zero)
To see this more carefully, consider the expected squared output of ReLU applied to :
The indicator is 1 when is positive and 0 when negative. Since has zero mean, , which is nonzero. The variance therefore equals . For large networks where the number of neurons is large, the mean contribution to variance is much smaller than , and the approximation holds well.
This variance halving has severe consequences for deep networks. After ReLU layers, variance shrinks by a factor of . A 10-layer ReLU network reduces activation variance by . A 20-layer network reduces it by over a million. Xavier initialization, calibrated assuming no such reduction, produces vanishing activations in deep ReLU networks.
Deriving He Initialization
Kaiming He and colleagues addressed this in their 2015 paper "Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification." Their derivation modifies the Xavier variance equation to include ReLU's variance reduction factor.
Starting from the variance propagation equation with the ReLU correction:
where:
- : variance of the activation output, that is, the distribution after applying ReLU
- : the variance reduction factor from ReLU zeroing all negative pre-activation values
- : fan-in (number of input connections)
- : variance of the weights in this layer
- : variance of the input activations from the previous layer
To maintain , we set:
Dividing both sides by :
Solving for the weight variance:
This is He initialization (also called Kaiming initialization). The factor of 2 compensates precisely for ReLU's variance-halving effect. Notice that He uses only rather than averaging and as Xavier does. He et al. found that matching forward pass variance was the more critical constraint for deep ReLU networks in practice, and empirical results confirmed that omitting the fan-out term worked better for the very deep convolutional networks they were studying.
A weight initialization scheme where weights are drawn from a distribution with variance . Designed specifically for ReLU networks, the factor of 2 in the numerator exactly compensates for the variance-halving effect of setting negative activations to zero.
Converting to distribution parameters:
where is the standard deviation (the square root of the target variance).
Uniform distribution: Using the same derivation as for Xavier, where the variance of equals , we solve to obtain :
Implementation and Comparison
def he_normal(shape):
"""He initialization with normal distribution."""
fan_in, fan_out = shape
std = np.sqrt(2 / fan_in)
return np.random.randn(*shape) * std
def he_uniform(shape):
"""He initialization with uniform distribution."""
fan_in, fan_out = shape
limit = np.sqrt(6 / fan_in)
return np.random.uniform(-limit, limit, shape)Comparing Xavier and He initialization on ReLU network: ------------------------------------------------------------ Xavier normal: Layer 0: std = 0.9990 Layer 1: std = 0.5859 Layer 2: std = 0.4019 Layer 3: std = 0.2649 Layer 4: std = 0.1818 Layer 5: std = 0.1210 Layer 6: std = 0.0794 Layer 7: std = 0.0576 Layer 8: std = 0.0443 Layer 9: std = 0.0320 Layer 10: std = 0.0238 He normal: Layer 0: std = 1.0011 Layer 1: std = 0.8270 Layer 2: std = 0.8115 Layer 3: std = 0.8722 Layer 4: std = 0.9080 Layer 5: std = 0.9697 Layer 6: std = 0.9750 Layer 7: std = 1.0024 Layer 8: std = 1.0809 Layer 9: std = 1.1509 Layer 10: std = 1.1800
He initialization maintains stable activation magnitudes in ReLU networks, while Xavier causes activations to decay layer by layer because it does not account for the variance reduction from ReLU.
