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.

Google
Machine Learning
Machine Learning Engineer
Google
November 29, 2026
Machine Learning Engineer
Technical Screen
Machine Learning
Medium

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
Weight initialization
Xavier initialization
He initialization
Activation variance
Training stability
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. 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 Prep
Sample Answer
Clarify

A fully connected layer yj=∑i=1nWjixiy_j = \sum_{i=1}^{n} W_{ji} x_i with weights i.i.d. zero mean variance σw2\sigma_w^2, independent of zero-mean inputs. We want Var(y)\text{Var}(y) to stay constant layer after lay...

Approach

Var(yj)=n σw2 E[xi2]\text{Var}(y_j) = n\,\sigma_w^2\,\mathbb{E}[x_i^2]. For linear or tanh (near zero) units, E[x2]=Var(yprev)\mathbb{E}[x^2] = \text{Var}(y_{prev}), so we need σw2=1/n\sigma_w^2 = 1/n. Applying the same argument to the b...


Submit Your Answer
Markdown supported