How do you derive the Xavier (Glorot) and He initialisation variances from the requirement that activation variance stays constant from layer to layer?
Deep learning, Optimisation of deep networks
Level L3 Intermediate. Length Long. Nature Mat Mathematical.
What's being asked
Whether you can do the variance calculation for a linear layer and adapt it to the activation function.
Key idea
Take , where is the fan-in (number of inputs) and the weights are independent and zero-mean, with variance . Then . Keeping this equal to the previous layer's variance gives for a zero-mean (tanh-like) activation, and for ReLU.
Steps
- Assumptions: weights i.i.d. (independent and identically distributed) with mean 0 and variance , independent of the inputs; biases 0.
- Variance of one term: . Summing independent terms: .
- Xavier: near 0, tanh is roughly linear and zero-mean, so . Keeping the forward variance needs . The same argument on the backward pass needs , where is the fan-out. Glorot's compromise is .
- Uniform version: has variance , so .
- He: with and symmetric about 0, ReLU zeroes half the mass, so . Then , and keeping it constant needs .
- Close with why it matters. After layers the variance is multiplied by , with (tanh) or (ReLU). This vanishes or explodes geometrically unless the factor is 1.
Common mistakes
- Writing for ReLU outputs. Their mean is not 0, so you need .
- Forgetting the factor for ReLU, which is the whole difference between Xavier and He.
- Mixing up fan-in and fan-out, or using where is meant.
How long your answer should be
About a page; 6–8 minutes.
Last checked on 4 December 2026.
Read this
Previous in Deep learning: With label smoothing on classes, what is the target distribution, and what is the gradient of the cross-entropy loss with respect to the logits? For , and true class 2, what are the target vector and the logit gap the model is pushed towards?
Next in Deep learning: In a variational autoencoder (VAE), the encoder outputs mean and log-variance for a scalar latent variable . How does the reparameterisation trick produce for auxiliary noise , why is it needed for backpropagation, and what are and ?