深度学习01

1 Brief Introduction of Deep Learning

在这里插入图片描述

Neural Network

确定参数
一个神经元中所有的w和b记为参数θ
在这里插入图片描述
确定神经元的连接方式:
Fully Connect Feedforward Network
在这里插入图片描述
用矩阵形式表示:
在这里插入图片描述
在这里插入图片描述

goodness of function

使用梯度下降求解使loss最小的θ,loss为交叉熵
在这里插入图片描述
在这里插入图片描述

Backpropagation反向传播

link
在这里插入图片描述

假设只有1层隐含层,激活函数默认为sigmoid。
当我们通过前向传播得到y_hat后,此时可以得到误差,为缩小误差,我们需要采用反向传播更新参数,这边以w5和w1的更新为例:
E = 1 2 ( y t r u e − y p r e ) 2 E=\frac{1}{2}(y_{true}-y_{pre})^2 E=21(ytrueypre)2
∂ E ∂ w 5 = ∂ E ∂ o u t ∂ o u t ∂ n e t ∂ n e t ∂ w 5 \frac{\partial E}{\partial w5}=\frac{\partial E}{\partial out}\frac{\partial out}{\partial net}\frac{\partial net}{\partial w5} w5E=outEnetoutw5net
∂ E ∂ o u t = − ( y t r u e − y p r e ) = − ( 0.01 − 0.751 ) = 0.741 \frac{\partial E}{\partial out}=-(y_{true}-y_{pre})=-(0.01-0.751)=0.741 outE=(ytrueypre)=(0.010.751)=0.741
∵ o u t = 1 1 + e − n e t \because out=\frac{1}{1+e^{-net}} out=1+enet1
∂ o u t ∂ n e t = o u t ( 1 − o u t ) = 0.751 ( 1 − 0.751 ) = 0.1868 \frac{\partial out}{\partial net}=out(1-out)=0.751(1-0.751)=0.1868 netout=out(1out)=0.751(10.751)=0.1868
∵ n e t = w 5 h 1 + w 6 h 2 \because net=w_{5}h1+w_{6}h2 net=w5h1+w6h2
∂ n e t ∂ w 5 = h 1 = 0.5932 \frac{\partial net}{\partial w5}=h1=0.5932 w5net=h1=0.5932
∴ ∂ E ∂ w 5 = 0.741 ∗ 0.1868 ∗ 0.5932 = 0.0821 \therefore \frac{\partial E}{\partial w5}=0.741*0.1868*0.5932=0.0821 w5E=0.7410.18680.5932=0.0821
再回过来看公式 ∂ E ∂ w 5 = − ( y t r u e − y p r e ) o u t ( 1 − o u t ) h 1 \frac{\partial E}{\partial w5}=-(y_{true}-y_{pre})out(1-out)h1 w5E=(ytrueypre)out(1out)h1
δ o l \delta_{ol} δol表示输出层的误差, δ o l = = ∂ E t o t a l ∂ o u t o l ∂ o u t o l ∂ n e t o l \delta_{ol}==\frac{\partial E_{total}}{\partial out_{ol}}\frac{\partial out_{ol}}{\partial net_{ol}} δol==outolEtotalnetoloutol,所以整体误差E(total)对w5的偏导公式可以写成: ∂ E t o t a l ∂ w 5 = δ o l o u t h 1 \frac{\partial E_{total}}{\partial w5}=\delta_{ol}out_{h1} w5Etotal=δolouth1.
最后我们来更新w5的值:
w 5 ′ = w 5 − η ∂ E t o t a l ∂ w 5 = 0.4 − 0.5 ∗ 0.0821 w_{5'} =w_{5}-\eta \frac{\partial E_{total}}{\partial w5}=0.4-0.5*0.0821 w5=w5ηw5Etotal=0.40.50.0821

更新隐含层参数w1:
∂ E o 1 ∂ w 1 = ( ∂ E o 1 ∂ o u t o 1 ∂ o u t o 1 ∂ n e t o 1 ∂ n e t o 1 ∂ h 1 + ∂ E o 2 ∂ o u t o 2 ∂ o u t o 2 ∂ n e t o 2 ∂ n e t o 2 ∂ h 2 ) ∂ h 1 ∂ n e t h 1 ∂ n e t h 1 ∂ w 1 \frac{\partial E_{o1}}{\partial w1}=(\frac{\partial E_{o1}}{\partial out_{o1}}\frac{\partial out_{o1}}{\partial net_{o1}}\frac{\partial net_{o1}}{\partial h_{1}}+\frac{\partial E_{o2}}{\partial out_{o2}}\frac{\partial out_{o2}}{\partial net_{o2}}\frac{\partial net_{o2}}{\partial h_{2}})\frac{\partial h_{1}}{\partial net_{h1}}\frac{\partial net_{h1}}{\partial w1} w1Eo1=(outo1Eo1neto1outo1h1neto1+outo2Eo2neto2outo2h2neto2)neth1h1w1neth1
∵ n e t o 1 = w 5 h 1 + w 6 h 2 + b \because net_{o1}=w_{5}h_{1}+w_{6}h_{2}+b neto1=w5h1+w6h2+b
∴ ∂ n e t o 1 ∂ h 1 = w 5 = 0.4 \therefore \frac{\partial net_{o1}}{\partial h1}=w_{5}=0.4 h1neto1=w5=0.4
∴ ∂ E o 1 ∂ h 1 = 0.741 ∗ 0.1868 ∗ 0.4 = 0.055 \therefore \frac{\partial E_{o1}}{\partial h1}=0.741*0.1868*0.4=0.055 h1Eo1=0.7410.18680.4=0.055
同理可求出:
∂ E o 2 ∂ h 2 = ∂ E o 2 ∂ o u t o 2 ∂ o u t o 2 ∂ n e t o 2 ∂ n e t o 2 ∂ h 2 = − 0.019 \frac{\partial E_{o2}}{\partial h2}=\frac{\partial E_{o2}}{\partial out_{o2}}\frac{\partial out_{o2}}{\partial net_{o2}}\frac{\partial net_{o2}}{\partial h_{2}}=-0.019 h2Eo2=outo2Eo2neto2outo2h2neto2=0.019

∂ h 1 ∂ n e t h 1 = n e t h 1 ( 1 − n e t h 1 ) = 0.5932 ( 1 − 0.5932 ) = 0.2413 \frac{\partial h_{1}}{\partial net_{h1}}=net_{h1}(1-net_{h1})=0.5932(1-0.5932)=0.2413 neth1h1=neth1(1neth1)=0.5932(10.5932)=0.2413

∂ n e t h 1 ∂ w 1 = i 1 = 0.05 \frac{\partial net_{h1}}{\partial w_{1}}=i_{1}=0.05 w1neth1=i1=0.05

∴ ∂ E t o t a l ∂ w 1 = ( 0.055 − 0.019 ) ∗ 0.2413 ∗ 0.05 = 0.0004 \therefore \frac{\partial E_{total}}{\partial w1}=(0.055−0.019)*0.2413*0.05=0.0004 w1Etotal=(0.0550.019)0.24130.05=0.0004

最后更新权重w1:
w 1 = w 1 − η ∂ E t o t a l ∂ w 1 = 0.15 − 0.5 ∗ 0.0004 = 0.1497 w_{1}=w_{1}-\eta \frac{\partial E_{total}}{\partial w1}=0.15-0.5*0.0004=0.1497 w1=w1ηw1Etotal=0.150.50.0004=0.1497

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值