前一段时间看了 Michael Nielsen写的文章,我觉得是目前看到讲神经网络后向传播算法讲的最好的一篇文章了。下面提其精要:
符号
wljk : the weight for the connection from the kth neuron in the (l−1)th layer to the jth neuron in the lth layerblj : the bias of the jth neuron in the lth layer
zlj : the weighted input
alj : the activation of the jth neuron in the lth layer
各符号的例子如下:
公式
z 和
a 的计算公式如下:
zlj=∑kwljkal−1k+blj
alj=σ(∑kwljkal−1k+blj)写成矩阵形式:
zl≡wlal−1+bl
al=σ(wlal−1+bl)损失函数:
C=12n∑x∥y(x)−aL(x)∥2后向传播算法intuition
对于 jth neuron in layer l , 如果我们让zlj 变化 Δzlj ,那么该神经元的输出由 σ(zlj) 变成了 σ(zlj+Δzlj) ,并且损失函数值变化了 ∂C∂zljΔzlj 。
所以我们可以让 Δzlj 和 ∂C∂zlj 符号相反,达到让损失函数值下降。一直到 ∂C∂zlj 无限接近0,那么此时无论怎么变化 zlj 都难以让损失函数值下降了,此时我们宣布:该神经元达到最优状态了.
基于这个观察,我们将neuron j in layerl 的误差 δlj 定义为:
δlj≡∂C∂zlj.后向传播算法的四大公式
详细解释:
BP1:
δLj=∂C∂aLjσ′(zLj)
δL=∇aC⊙σ′(zL)
δL=(aL−y)⊙σ′(zL)
BP2:
δl=((wl+1)Tδl+1)⊙σ′(zl)
BP3:
∂C∂blj=δlj
∂C∂b=δ
BP4:
∂C∂wljk=al−1kδlj
∂C∂w=ainδout