Back to Deep Learning Mind Map
中文·English
🧠 Deep LearningID: kaiming-init-derivation

Kaiming Init Derivation

Kaiming 初始化方差推导
🎯Core Definition
The Kaiming (He) initialization derivation constructs a variance-preserving weight distribution for ReLU networks, concluding Var(w)=2/din\text{Var}(w) = 2/d_{\text{in}}. Full derivation chain: ① Core identity: for a single output neuron y=i=1dwixiy = \sum_{i=1}^{d} w_i x_i (d=dind = d_{\text{in}}), with wiw_i i.i.d., E[wi]=0E[w_i] = 0 and wiw_i independent of xix_i, Var(y)=i=1dVar(wixi)=i=1d(E[wi2]E[xi2]E[wi]2E[xi]2)\text{Var}(y) = \sum_{i=1}^{d}\text{Var}(w_i x_i) = \sum_{i=1}^{d}\left(E[w_i^2]E[x_i^2] - E[w_i]^2E[x_i]^2\right). Since zero-mean ww, xx give Var(w)=E[w2]\text{Var}(w)=E[w^2], Var(x)=E[x2]\text{Var}(x)=E[x^2], we get Var(y)=dE[w2]E[x2]=dVar(w)Var(x)\text{Var}(y) = d\,E[w^2]\,E[x^2] = d\,\text{Var}(w)\,\text{Var}(x). ② Linear case: without an activation (or with a linear one), setting Var(y)=Var(x)\text{Var}(y) = \text{Var}(x) yields dVar(w)=1Var(w)=1/dd\,\text{Var}(w) = 1 \Rightarrow \text{Var}(w) = 1/d, which is Xavier's forward condition. ③ The role of ReLU: assume the pre-activation z=wTxz = w^Tx is zero-mean and symmetric about 0 (guaranteed by zero-mean symmetric ww, xx), so P(z<0)=1/2P(z<0) = 1/2; the output x=max(0,z)x' = \max(0, z) zeroes the negative half, and its mean-square energy is E[(x)2]=0z2p(z)dz=12z2p(z)dz=12Var(z)E[(x')^2] = \int_0^{\infty} z^2 p(z)\,dz = \tfrac{1}{2}\int_{-\infty}^{\infty} z^2 p(z)\,dz = \tfrac{1}{2}\text{Var}(z) — ReLU exactly halves the activation energy. ④ Feed into the next layer: Var(y)=dE[w2]E[(x)2]=dVar(w)12Var(x)\text{Var}(y') = d\,E[w^2]\,E[(x')^2] = d\,\text{Var}(w)\cdot\tfrac{1}{2}\text{Var}(x) (the previous layer already keeps Var(z)=Var(x)\text{Var}(z) = \text{Var}(x)); setting Var(y)=Var(x)\text{Var}(y') = \text{Var}(x) gives 12dVar(w)=1Var(w)=2d\tfrac{1}{2}d\,\text{Var}(w) = 1 \Rightarrow \text{Var}(w) = \frac{2}{d}. Where the factor 2 comes from: ReLU halves the activation energy each layer, so the weight variance must double to preserve variance. ⑤ Backward condition: the gradient Lx=WTLy\frac{\partial L}{\partial x} = W^T\frac{\partial L}{\partial y} is also a sum of doutd_{\text{out}} terms, and ReLU's derivative is 1 on the positive half and 0 on the negative half (gradient pass-through is also ½), so backward variance preservation requires Var(w)=2/dout\text{Var}(w) = 2/d_{\text{out}}. Forward uses fan_in, backward uses fan_out; frameworks such as PyTorch default to fan_in (dind_{\text{in}}). ⑥ PReLU generalization (negative slope aa): Var(w)=2(1+a2)din\text{Var}(w) = \frac{2}{(1+a^2)d_{\text{in}}}; a=0a=0 recovers ReLU's 2/din2/d_{\text{in}}.
💡Use Cases
a top interview derivation question (“derive the factor 2 in Kaiming init”), and the theoretical basis for the default initialization (kaiming_uniform) of all ReLU deep networks such as ResNet.
Key Problems Solved
without the factor-2 compensation, each layer multiplies forward activation variance and backward gradient variance by ½, so after 50 layers signals vanish at (1/2)501015(1/2)^{50} \approx 10^{-15} — vanishing gradients; Kaiming keeps every layer's variance at 1, so signals traverse dozens or hundreds of layers stably. It also avoids ReLU saturation (weights too large push inputs into the negative half where gradients are 0 — dead neurons) and keeps the initial output magnitude at O(1)O(1), matching the loss scale for stable first updates.
🎯5 High-Frequency Exam Points
1
Full derivation: from Var(y)=dE[w2]E[x2]\text{Var}(y) = d\,E[w^2]\,E[x^2], through ReLU zeroing, derive Var(w)=2/din\text{Var}(w) = 2/d_{\text{in}} (write every step, including the zero-mean and independence assumptions).
2
Derive the factor 2: use the integral E[(x)2]=12Var(z)E[(x')^2] = \tfrac{1}{2}\text{Var}(z) to show how ReLU zeroing halves the activation energy; which assumptions does it rely on (zero mean, symmetric distribution, ww independent of xx)?
3
Why are the forward and backward variance-preserving conditions 2/din2/d_{\text{in}} and 2/dout2/d_{\text{out}} respectively? How does ReLU's ½ gradient pass-through enter the backward derivation? Which does the framework default to (fan_in)?
4
Kaiming vs Xavier: how does Var(w)=2/d\text{Var}(w) = 2/d reduce to 1/d1/d without ReLU? Why do tanh networks use Xavier while ReLU networks must use Kaiming (what goes wrong with 1/d1/d)?
5
PReLU generalization: how does Var(w)=2(1+a2)din\text{Var}(w) = \frac{2}{(1+a^2)d_{\text{in}}} follow from E[(x)2]=1+a22Var(z)E[(x')^2] = \tfrac{1+a^2}{2}\text{Var}(z); if the assumptions break (asymmetric or nonzero-mean inputs), which step of the derivation fails?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Kaiming Init Derivation"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardWeight InitializationNext CardGradient Clipping

🔗 More Deep Learning Knowledge Cards

Activation FunctionsAdam & AdamWAutograd Compute GraphBatch Normalization