← Back to Deep Learning Mind Map
🧠 Deep LearningID: weight-init

Weight Initialization

权重初始化
🎯Core Definition
Weight initialization chooses a distribution for the weights before training, aiming to keep the variance of forward activations and backward gradients preserved across layers (neither shrinking nor exploding), avoiding vanishing/exploding gradients. Zero or identical initialization is the anti-pattern: all neurons in a layer share the same weights → identical outputs and gradients → symmetry never breaks and every neuron learns the same function (equivalent to one neuron). Xavier/Glorot (2010, for the near-linear regime of tanh/sigmoid): forward variance preservation requires Var(w)=1/din\text{Var}(w) = 1/d_{\text{in}}, backward Var(w)=1/dout\text{Var}(w) = 1/d_{\text{out}}; the compromise is Var(w)=2din+dout\text{Var}(w) = \frac{2}{d_{\text{in}} + d_{\text{out}}}; uniform form w∼U[−6din+dout,6din+dout]w \sim U\left[-\sqrt{\frac{6}{d_{\text{in}}+d_{\text{out}}}}, \sqrt{\frac{6}{d_{\text{in}}+d_{\text{out}}}}\right] (since U[−a,a]U[-a,a] has variance a2/3a^2/3, setting a2/3=2/(din+dout)a^2/3 = 2/(d_{\text{in}}+d_{\text{out}}) gives a=6/(din+dout)a = \sqrt{6/(d_{\text{in}}+d_{\text{out}})}), or normal N(0,2/(din+dout))N(0, 2/(d_{\text{in}}+d_{\text{out}})). Kaiming/He (2015, for ReLU): Var(w)=2din\text{Var}(w) = \frac{2}{d_{\text{in}}}, uniform U[−6din,6din]U\left[-\sqrt{\frac{6}{d_{\text{in}}}}, \sqrt{\frac{6}{d_{\text{in}}}}\right] or normal N(0,2/din)N(0, 2/d_{\text{in}}); PReLU generalizes to Var(w)=2(1+a2)din\text{Var}(w) = \frac{2}{(1+a^2)d_{\text{in}}} (aa = negative-slope coefficient). Core derivation (assuming E[w]=0E[w]=0 and xx independent of ww): for one output y=∑iwixiy = \sum_i w_i x_i, Var(y)=din Var(w) Var(x)\text{Var}(y) = d_{\text{in}}\,\text{Var}(w)\,\text{Var}(x); setting output variance equal to input variance gives Var(w)=1/din\text{Var}(w) = 1/d_{\text{in}}, and ReLU halves the activation energy (zeroing the negative half), hence the factor 2.
💡Use Cases
the first line of defense in training any deep network (CNN/Transformer), complementary to BatchNorm (BN mitigates but does not fully fix a bad initialization); interview favorites: why zero-init fails, Xavier vs Kaiming selection, and how initialization relates to vanishing/exploding gradients.
⚡Key Problems Solved
weights too large → activation saturation (tanh derivative → 0 at the tails) or forward explosion; weights too small → exponential decay of signals (on the order of 0.950≈0.0050.9^{50} \approx 0.005 after 50 layers). Variance-preserving initialization keeps signal magnitudes at O(1)O(1) throughout, making dozens-to-hundreds-of-layer networks trainable. Note initialization only sets the starting point: long-term control of vanishing/exploding gradients also needs skip connections, BN/LN and gating — initialization complements, not replaces, them.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Weight Initialization.
Use Cases
In production engineering, what are the primary use cases for Weight Initialization and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Why can't all weights be initialized to 0 (or the same value)? Explain the symmetry problem: identical initialization → identical gradients → symmetry never breaks → equivalent to a single neuron.
2
Derive Xavier's forward condition: from Var(y)=d Var(w) Var(x)\text{Var}(y) = d\,\text{Var}(w)\,\text{Var}(x) and variance preservation get Var(w)=1/din\text{Var}(w) = 1/d_{\text{in}}; why does the final formula average as 2/(din+dout)2/(d_{\text{in}}+d_{\text{out}}) (compromise between 1/din1/d_{\text{in}} forward and 1/dout1/d_{\text{out}} backward)?
3
Write Xavier and Kaiming formulas and their activation targets: tanh/sigmoid → Xavier (2/(din+dout)2/(d_{\text{in}}+d_{\text{out}})), ReLU → Kaiming (2/din2/d_{\text{in}}); why (ReLU zeroes half → factor 2)?
4
Where does the uniform bound 6/(din+dout)\sqrt{6/(d_{\text{in}}+d_{\text{out}})} come from? Solve a2/3=2/(din+dout)a^2/3 = 2/(d_{\text{in}}+d_{\text{out}}) for U[−a,a]U[-a,a].
5
Initialization vs vanishing/exploding gradients: how does the initial variance determine signal propagation (magnitudes of forward activations and backward gradients); why are initialization and BN complementary?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "Weight Initialization"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardLearning Rate SchedulingNext Card →Kaiming Init Derivation

🔗 More Deep Learning Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/DL/card/weight-init
中文速览与面试要点

权重初始化 (Weight Initialization)

定义: 权重初始化 = 训练开始前为权重选择分布,目标是让前向激活与反向梯度在层间传递时方差保持(既不明显缩小、也不明显放大),从而不触发梯度消失/爆炸。零初始化或全部相同初始化是错误示范: 同层所有神经元权重相同 → 前向输出相同、反向梯度也相同 → 对称性无法破缺,所有神经元永远学习到同一功能(等价于一个神经元)。Xavier/Glorot 初始化(2010,面向 tanh/sigmoid 的近似线性区): 前向方差保持要求 Var(w) = 1/d_ in,反向要求 Var(w) = 1/d_ out,取折中 Var(w) = 2d_ in + d_ out;均匀分布形式 w U [- 6d_ in+d_ out, 6d_ in+d_ out ](U[-a,a] 的方差为 a^2/3,令 a^2/3 = 2/(d_ in+d_ out) 反解出 a = 6/(d_ in+d_ out)),或正态 N(0, 2/(d_ in+d_ out))。Kaiming/He 初始化(2015,面向 ReLU): Var(w) = 2d_ in,均匀 U [- 6d_ in, 6d_ in ] 或正态 N(0, 2/d_ in);PReLU 推广为 Var(w) = 2(1+a^2)d_ in(a 为负半轴斜率)。核心推导(设 E[w]=0、x 与 w 独立): 单输出 y = _i w_i x_i 满足 Var(y) = d_ in\, Var(w)\, Var(x),令输出方差等于输入方差即得 Var(w) = 1/d_ in;ReLU 把激活均方砍半(负半轴置零),故乘 2 得 2/d_ in。 使用场景: 任何深度网络(CNN/Transformer)训练的第一道防线,与 BatchNorm 互补(BN 能缓解但初始化差仍会导致前几层梯度病态);面试高频“为什么不能零初始化”“Xavier 与 Kaiming 怎么选”“初始化如何影响梯度消失/爆炸”。 解决的问题: 权重过大 → 激活饱和(tanh 端部导数趋近 0)或前向数值爆炸;权重过小 → 深层信号指数衰减(50 层后按 0.9^50 0.005 量级消失)。方差保持的初始化让信号量级在前向/反向全程保持 O(1),使几十上百层的网络可训练。注意初始化只决定起点: 梯度消失/爆炸的长期演化还要靠残差连接、BN/LN、门控等结构性手段,初始化与它们互补而非替代。

核心要点

  • 为什么不能把所有权重初始化为 0(或相同值)?写出对称性问题: 相同初始化 → 相同梯度 → 对称性永不破缺 → 等价于一个神经元。
  • 推导 Xavier 前向条件: 由 Var(y) = d\, Var(w)\, Var(x) 令方差保持得 Var(w) = 1/d_ in;为什么最终取 2/(d_ in+d_ out)(前向 1/d_ in 与反向 1/d_ out 的折中)?
  • 写出 Xavier 与 Kaiming 的公式及适用激活: tanh/sigmoid 用 Xavier(2/(d_ in+d_ out)),ReLU 用 Kaiming(2/d_ in);原因是什么(ReLU 置零一半 → 因子 2)?
  • 均匀分布边界 6/(d_ in+d_ out) 怎么来的?由 U[-a,a] 方差 a^2/3 等于目标方差 2/(d_ in+d_ out) 反解。
  • 初始化与梯度消失/爆炸: 深度网络中初始化方差如何决定信号传递(前向激活与反向梯度的量级);为什么说初始化与 BN 是互补手段?