The Kaiming (He) initialization derivation constructs a variance-preserving weight distribution for ReLU networks, concluding
Var(w)=2/din. Full derivation chain: ① Core identity: for a single output neuron
y=∑i=1dwixi (
d=din), with
wi i.i.d.,
E[wi]=0 and
wi independent of
xi,
Var(y)=∑i=1dVar(wixi)=∑i=1d(E[wi2]E[xi2]−E[wi]2E[xi]2). Since zero-mean
w,
x give
Var(w)=E[w2],
Var(x)=E[x2], we get
Var(y)=dE[w2]E[x2]=dVar(w)Var(x). ② Linear case: without an activation (or with a linear one), setting
Var(y)=Var(x) yields
dVar(w)=1⇒Var(w)=1/d, which is Xavier's forward condition. ③ The role of ReLU: assume the pre-activation
z=wTx is zero-mean and symmetric about 0 (guaranteed by zero-mean symmetric
w,
x), so
P(z<0)=1/2; the output
x′=max(0,z) zeroes the negative half, and its mean-square energy is
E[(x′)2]=∫0∞z2p(z)dz=21∫−∞∞z2p(z)dz=21Var(z) — ReLU exactly halves the activation energy. ④ Feed into the next layer:
Var(y′)=dE[w2]E[(x′)2]=dVar(w)⋅21Var(x) (the previous layer already keeps
Var(z)=Var(x)); setting
Var(y′)=Var(x) gives
21dVar(w)=1⇒Var(w)=d2. 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
∂x∂L=WT∂y∂L is also a sum of
dout 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. Forward uses fan_in, backward uses fan_out; frameworks such as PyTorch default to fan_in (
din). ⑥ PReLU generalization (negative slope
a):
Var(w)=(1+a2)din2;
a=0 recovers ReLU's
2/din.