Derive Xavier and He Initialization From Activation Variance
Last updated: November 29, 2026
Quick Overview
Derive the weight variance that keeps activation variance constant through a deep network for linear or tanh units and for ReLU units, and show what happens with a naive small-constant initialization.
0
0
0 solved
Derive the weight variance that keeps activation variance constant through a deep network for linear or tanh units and for ReLU units, and show what happens with a naive small-constant initialization.
Google ML screens like this because it tests whether a candidate can reason from first principles about training dynamics instead of trusting framework defaults. The interviewer wants the variance derivation, the factor of 2 for ReLU, and a quick experiment to confirm it.
What the Interviewer Expects
- Writes the variance of a pre-activation as fan-in times weight variance times input second moment
- Derives variance 1/fan_in (or 2/(fan_in + fan_out)) for Xavier
- Derives the extra factor of 2 for ReLU
- Runs or describes a depth experiment showing collapse or explosion
- Connects initialization to residual scaling in Transformers
- Notes that normalization layers reduce but do not remove sensitivity
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- Why does Xavier average fan-in and fan-out?
- How would you initialize the output projection of each residual branch in a deep Transformer?
- Does initialization still matter with layer normalization everywhere?
- How does initialization interact with the learning rate under Adam?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
A fully connected layer with weights i.i.d. zero mean variance , independent of zero-mean inputs. We want to stay constant layer after lay...
Approach
. For linear or tanh (near zero) units, , so we need . Applying the same argument to the b...