前向:先保存中間計算Forward pass: save intermediate values

IDL115 · CH03 · KP06 · 12/44
梯度回傳之前,先知道每層做過什麼。 / Save each layer’s computations before propagating derivatives.

加權輸入Pre-activation

wᵢℓ 從前一層 ℓ 連到本層 i;偏置可另加。 / The edge runs from ℓ to i.

ai=∑ℓ=1mwiℓzℓ+bi(9)a_i=\sum_{\ell=1}^m w_{i\ell}z_\ell+b_i\quad\text{(9)}

激活輸出Activation

σ 是非線性函數;z 是送往下一層的值。 / Activation creates the next layer’s input.

zi=σi(ai)(10)z_i=\sigma_i(a_i)\quad\text{(10)}

保存後再回傳Cache, then backpropagate

保存 a、z 與損失;計算整批梯度後才更新參數。 / Compute all gradients before changing weights.