机器学习笔记之反向传播算法

Backpropagation Algorithm

"Backpropagation" is neural-network terminology for minimizing our cost function, just like what we were doing with gradient descent in logistic and linear regression. Our goal is to compute:

minΘJ(Θ)

That is, we want to minimize our cost function J using an optimal set of parameters in theta. In this section we'll look at the equations we use to compute the partial derivative of J(Θ):

Θ(l)i,jJ(Θ)

To do so, we use the following algorithm:


Back propagation Algorithm

Given training set  {(x(1),y(1))(x(m),y(m))}

  • Set  Δ(l)i,j  := 0 for all (l,i,j), (hence you end up having a matrix full of zeros)

For training example t =1 to m:

  1. Set  a(1):=x(t)
  2. Perform forward propagation to compute  a(l)  for l=2,3,…,L

3. Using  y(t) , compute  δ(L)=a(L)y(t)

Where L is our total number of layers and  a(L)  is the vector of outputs of the activation units for the last layer. So our "error values" for the last layer are simply the differences of our actual results in the last layer and the correct outputs in y. To get the delta values of the layers before the last layer, we can use an equation that steps us back from right to left:

4. Compute  δ(L1),δ(L2),,δ(2)  using  δ(l)=((Θ(l))Tδ(l+1)) . a(l) . (1a(l))

The delta values of layer l are calculated by multiplying the delta values in the next layer with the theta matrix of layer l. We then element-wise multiply that with a function called g', or g-prime, which is the derivative of the activation function g evaluated with the input values given by  z(l) .

The g-prime derivative terms can also be written out as:

g(z(l))=a(l) . (1a(l))

5.  Δ(l)i,j:=Δ(l)i,j+a(l)jδ(l+1)i  or with vectorization,  Δ(l):=Δ(l)+δ(l+1)(a(l))T

Hence we update our new  Δ  matrix.

  • D(l)i,j:=1m(Δ(l)i,j+λΘ(l)i,j) , if j≠0.
  • D(l)i,j:=1mΔ(l)i,j  If j=0

The capital-delta matrix D is used as an "accumulator" to add up our values as we go along and eventually compute our partial derivative. Thus we get  Θ(l)ijJ(Θ) D(l)ij

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值