完整回傳:算完,再更新Complete backprop: compute, then update

IDL115 · CH03 · KP06 · 15/44
實算一個 1→1→1 網路,追蹤每個梯度。 / Trace every derivative in a one-hidden-unit network.

前向範例Forward example

x=1、u=0.5、v=2、隱藏 ReLU、輸出線性、目標 y=0。 / A positive ReLU branch is active.

h=max⁡(0,ux)=0.5,y^=vh=1,e=12(y^−y)2=0.5h=\max(0,ux)=0.5,\quad\hat y=vh=1,\quad e=\tfrac12(\hat y-y)^2=0.5

輸出與隱藏梯度Backward example

輸出 δ=1,隱藏 δ=2。 / Output delta is 1; hidden delta is 2.

∂e∂v=1×0.5=0.5,∂e∂u=2×1=2\frac{\partial e}{\partial v}=1\times0.5=0.5,\qquad\frac{\partial e}{\partial u}=2\times1=2

同步更新Simultaneous update

η=0.1 時 u=0.3、v=1.95;重新前向後 e≈0.1711。 / Recompute after both updates.

wiℓ+=wiℓ−ηδizℓ(17)–(19)w^+_{i\ell}=w_{i\ell}-\eta\delta_i z_\ell\quad\text{(17)–(19)}