手算反向传播:输出层误差项与参数梯度
Agent辅助工程检查
前置要求
第34日 N1 的前向账本:$o=3.1255$,$L=4.5179$。
学习目标
对 N1 的线性输出与平方损失 $L=(o - y)^2$ 分步应用链式法则,求输出误差项与三个输出层参数梯度。
操作指引
先推符号,再代数值。N1 的输出是线性单元 $o=w_{o1}a_1+w_{o2}a_2+b_o$,不是 sigmoid;损失没有 $1/2$ 系数。
1. $\delta_o=\partial L/\partial o=2(o-y)$。
2. 局部输入导数为 $\partial o/\partial a_1=w_{o1}$、$\partial o/\partial a_2=w_{o2}$。
3. 局部参数导数为 $a_1$、$a_2$、$1$,因此参数梯度是上游 $\delta_o$ 乘局部导数。
4. 使用第34日 $a_1=0.8741$、$a_2=-0.9757$、$o=3.1255$、$y=1.0$ 预测三个输出梯度,再看答案。
自主演练与记录
1. 推导 $\delta_o$。2. 算出两个输出权重与偏置的梯度。3. 解释线性单元偏置的局部导数为何是1。4. 指出传到 $a_1$ 的梯度还需通过哪个激活导数才能到达 $z_1$。
$\delta_o=2(3.1255-1.0)=4.2511$;权重乘对应激活,偏置的局部导数是1。
$\delta_o=4.2511$;$\partial L/\partial w_{o1}=4.2511\times0.8741=3.7157$,$\partial L/\partial w_{o2}=4.2511\times(-0.9757)=-4.1480$,$\partial L/\partial b_o=4.2511$。偏置以系数1进入线性输出。到达 $a_1$ 的梯度是 $\delta_o w_{o1}=4.2511$,还需乘 $\tanh'(z_1)=1-a_1^2$。
不看答案重现全部三个输出梯度(3.7157、-4.1480、4.2511),与引擎误差小于 $10^{-3}$,并解释上游乘局部的结构。
权威源资源与权利证明
Neural Networks and Deep Learning: How the backpropagation algorithm works
对应章节 / 时间戳: The four fundamental equations of backpropagation
验证版本与日期: Online book (Verified: 2026-10-30)
Clear four-equation derivation of backpropagation with scalar and matrix notation.
Matrix multiplication and the multivariable chain rule from Days 19-24.
All four backprop equations and derivations are self-contained within the lesson text.
对比候选资源与选型分析 (2)
Comprehensive graduate reference, but heavier tensor notation than needed for first MLP derivations.
Modular computational graph view; used as secondary source on Days 35-36.
CS231n: Backpropagation and Intuitions
对应章节 / 时间戳: Patterns in backward flow
验证版本与日期: Course notes (Verified: 2026-10-30)
Modular local-gradient interpretation (gate operations: add, multiply, max) and gradient flow intuition.
Multivariable calculus and basic Python.
Local gate definitions and circuit flow diagrams in the lesson provide full coverage.
对比候选资源与选型分析 (2)
Raw circuit view; CS231n notes are more structured with explicit gate derivations.
Top-down approach; CS231n bottom-up modular view matches our first-principles curriculum.