当前位置: 首页 > news >正文

网站建设口号品牌整合营销方案

网站建设口号,品牌整合营销方案,河南网站建设公,嘉定北京网站建设1️⃣ 原理分析 RNN前向传播的公式为: x t x_t xt​是t时刻的输入 s t s_t st​是t时刻的记忆, s t f ( U ⋅ x t W ⋅ s t − 1 ) s_tf(U\cdot x_tW\cdot s_{t-1}) st​f(U⋅xt​W⋅st−1​),f表示激活函数, s t − 1 s_{t-1} …

1️⃣ 原理分析

在这里插入图片描述
RNN前向传播的公式为:

  • x t x_t xt是t时刻的输入
  • s t s_t st是t时刻的记忆, s t = f ( U ⋅ x t + W ⋅ s t − 1 ) s_t=f(U\cdot x_t+W\cdot s_{t-1}) st=f(Uxt+Wst1),f表示激活函数, s t − 1 s_{t-1} st1表示t-1时刻的记忆
  • o t o_t ot是t时刻的输出, o t = s o f t m a x ( V ⋅ s t ) o_t=softmax(V\cdot s_t) ot=softmax(Vst)

采用交叉熵作为损失函数:
L = ∑ i = 1 T − o t ˉ l o g o t L=\sum_{i=1}^{T}-\bar{o_{t}}logo_{t} L=i=1Totˉlogot
其中T代表时间步的长度, o ˉ t \bar o_{t} oˉt代表ground truth, o t o_t ot代表预测的输出。

假设有三个时间步, t = 1 , 2 , 3 t=1,2,3 t=1,2,3。假设初始记忆 s t = 0 s_t=0 st=0,则 t = 1 t=1 t=1时的记忆和输出为:
s 1 = f ( U x 1 + W s 0 ) o 1 = f [ V ⋅ f ( U x 1 + W s 0 ) ] \begin{aligned}&s_1=f(Ux_1+Ws_0)\\&o_{1}=f[V\cdot f(Ux_{1}+Ws_{0})]\end{aligned} s1=f(Ux1+Ws0)o1=f[Vf(Ux1+Ws0)]
t = 2 t=2 t=2时的记忆和输出为:
s 2 = f ( U x 2 + W s 1 ) o 2 = f [ V ⋅ f ( U x 2 + W s 1 ) ] = f [ V ⋅ f ( U x 2 + W f ( U x 1 + W s 0 ) ) ] \begin{aligned}&s_2=f(Ux_2+Ws_1)\\&o_{2}=f[V\cdot f(Ux_{2}+Ws_{1})]=f[V\cdot f(Ux_{2}+Wf(Ux_1+Ws_0))]\end{aligned} s2=f(Ux2+Ws1)o2=f[Vf(Ux2+Ws1)]=f[Vf(Ux2+Wf(Ux1+Ws0))]

这样很晕,我来画个箭头:
在这里插入图片描述
可以发现 s 2 s_2 s2 s 1 s_1 s1的函数

t = 3 t=3 t=3时的记忆和输出为:
s 3 = f ( U x 3 + W s 2 ) o 3 = f [ V ⋅ f ( U x 3 + W s 2 ) ] = f [ V ⋅ f ( U x 3 + W f ( U x 2 + W s 1 ) ) ] = f [ V ⋅ f ( U x 3 + W f ( U x 2 + W f ( U x 1 + W s 0 ) ) ) ] \begin{aligned}&s_3=f(Ux_3+Ws_2)\\&o_{3}=f[V\cdot f(Ux_{3}+Ws_{2})]=f[V\cdot f(Ux_{3}+Wf(Ux_2+Ws_1))]=f[V\cdot f(Ux_{3}+Wf(Ux_2+Wf(Ux_1+Ws_0)))] \end{aligned} s3=f(Ux3+Ws2)o3=f[Vf(Ux3+Ws2)]=f[Vf(Ux3+Wf(Ux2+Ws1))]=f[Vf(Ux3+Wf(Ux2+Wf(Ux1+Ws0)))]
画个箭头:
在这里插入图片描述
可以发现 s 3 s_3 s3 s 2 s_2 s2的函数,又 s 2 s_2 s2 s 1 s_1 s1的函数,因此 s 3 s_3 s3包含 s 2 s_2 s2 s 1 s_1 s1

然后我们来分析反向传播:BPTT(Back-Propagation Through Time,时间上的反向传播)是针对RNN的训练算法,它的核心依然是基于梯度下降的反向传播。对于RNN来说,主要参数包括U、W和V。
在这里插入图片描述
以t=3时举例子,求U,V,W的梯度:
∂ L 3 ∂ V = ∂ L 3 ∂ o 3 ∂ o 3 ∂ V 3 ◯ ∂ L 3 ∂ W = ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 3 ∂ s 3 ∂ W + ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 2 ∂ s 2 ∂ W + ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 3 ∂ s 3 ∂ s 2 ∂ s 2 ∂ s 1 ∂ s 1 ∂ W 4 ◯ ∂ L 3 ∂ U = ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 3 ∂ s 3 ∂ U + ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 2 ∂ s 2 ∂ U + ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 3 ∂ s 3 ∂ s 2 ∂ s 2 ∂ s 1 ∂ s 1 ∂ U 5 ◯ \begin{aligned} &\frac{\partial L_3}{\partial V} =\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial V}\textcircled{3} \\ &\frac{\partial L_3}{\partial W} =\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_3}\frac{\partial s_3}{\partial W}+\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_2}\frac{\partial s_2}{\partial W}+\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_3}\frac{\partial s_3}{\partial s_2}\frac{\partial s_2}{\partial s_1}\frac{\partial s_1}{\partial W}\textcircled{4} \\ &\frac{\partial L_3}{\partial U} =\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_3}\frac{\partial s_3}{\partial U}+\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_2}\frac{\partial s_2}{\partial U}+\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_3}\frac{\partial s_3}{\partial s_2}\frac{\partial s_2}{\partial s_1}\frac{\partial s_1}{\partial U}\textcircled{5} \end{aligned} VL3=o3L3Vo33WL3=o3L3s3o3Ws3+o3L3s2o3Ws2+o3L3s3o3s2s3s1s2Ws14UL3=o3L3s3o3Us3+o3L3s2o3Us2+o3L3s3o3s2s3s1s2Us15

对于公式⑤可以简写成:
∂ L 3 ∂ U = ∑ k = 0 3 ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 3 ∂ s 3 ∂ s k ∂ s k ∂ U \frac{\partial L_3}{\partial U}=\sum_{k=0}^3\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_3}\frac{\partial s_3}{\partial s_k}\frac{\partial s_k}{\partial U} UL3=k=03o3L3s3o3sks3Usk

由于 ∂ s 3 ∂ s k \frac{\partial s_3}{\partial s_k} sks3也需要链式法则,即 ∂ s 3 ∂ s 1 = ∂ s 3 ∂ s 2 ∂ s 2 ∂ s 1 \frac{\partial s_3}{\partial s_1}=\frac{\partial s_3}{\partial s_2}\frac{\partial s_2}{\partial s_1} s1s3=s2s3s1s2。因此公式可以进一步修改为:

∂ L 3 ∂ U = ∑ k = 1 3 ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 3 ∂ s 3 ∂ s k ∂ s k ∂ U = ∑ k = 1 3 ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 3 ( ∏ j = k + 1 3 ∂ s j ∂ s j − 1 ) ∂ s k ∂ U 6 ◯ \frac{\partial L_3}{\partial U}=\sum_{k=1}^3\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_3}\frac{\partial s_3}{\partial s_k}\frac{\partial s_k}{\partial U}=\sum_{k=1}^3\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_3}(\prod_{j=k+1}^3\frac{\partial s_j}{\partial s_{j-1}})\frac{\partial s_k}{\partial U}\textcircled{6} UL3=k=13o3L3s3o3sks3Usk=k=13o3L3s3o3(j=k+13sj1sj)Usk6

同理,对公式④也可以写为:
∂ L 3 ∂ W = ∑ k = 1 3 ∂ L 3 ∂ o 3 ∂ o 3 ∂ s 3 ( ∏ j = k + 1 3 ∂ s j ∂ s j − 1 ) ∂ s k ∂ W 7 ◯ \frac{\partial L_3}{\partial W}=\sum_{k=1}^3\frac{\partial L_3}{\partial o_3}\frac{\partial o_3}{\partial s_3}(\prod_{j=k+1}^3\frac{\partial s_j}{\partial s_{j-1}})\frac{\partial s_k}{\partial W}\textcircled{7} WL3=k=13o3L3s3o3(j=k+13sj1sj)Wsk7

观察③式,对与V的偏导不存在依赖关系。

观察④和⑤式,对W和U求偏导的时候,存在长期依赖关系。原因是前向传播的时候 s t s_t st会随着时间向前传播,而 s t s_t st是W、U的函数。

假设激活函数为tanh,将⑥⑦中累乘部分取出来:
∏ j = k + 1 3 ∂ s j ∂ s j − 1 = ∏ j = k + 1 3 t a n h ′ W \prod_{j=k+1}^3\frac{\partial s_j}{\partial s_{j-1}}=\prod_{j=k+1}^3tanh^{'}W j=k+13sj1sj=j=k+13tanhW
例如: s 3 = f ( U x 3 + W s 2 ) s_3=f(Ux_3+Ws_2) s3=f(Ux3+Ws2) ∂ s 3 ∂ s 2 = t a n h ′ ( U ) W \frac{\partial s3}{\partial s_{2}}=tanh'(U) W s2s3=tanh(U)W
在这里插入图片描述

由上图可知,tanh的梯度最大为1,通常情况下会小于1,因此当t很大的时候,例如t=100时,⑥⑦中的累乘部分 ∏ j = k + 1 100 t a n h ′ W \prod_{j=k+1}^{100}tanh^{^{\prime}}W j=k+1100tanhW将趋于0,因此t=100时对于W和U的梯度将趋于0,导致梯度消失。

分析完tanh,再来分析一下W,如果W中的值太大,那么产生问题就是梯度爆炸


2️⃣ 总结

  • RNN存在梯度消失的原因是:隐藏层的输出 s t s_t st会向前传播,这样导致在反向传播求梯度时存在一个累乘项,这个累乘项由激活函数的梯度参数W组成,如果我们采用tanh作为激活函数,其梯度小于1,时间步越多,累乘项越趋近于0,导致梯度消失。
  • RNN存在梯度爆炸的原因:参数W如果过大,则会导致累乘项逐渐变大,导致梯度爆炸

3️⃣ 参考

RNN梯度消失与梯度爆炸的原因 - Hideonbush的文章 - 知乎



文章转载自:
http://wanjiabayesian.bpcf.cn
http://wanjiaconnubially.bpcf.cn
http://wanjiawebernesque.bpcf.cn
http://wanjiagudgeon.bpcf.cn
http://wanjiachristocentrism.bpcf.cn
http://wanjiafont.bpcf.cn
http://wanjialoquat.bpcf.cn
http://wanjiaaerobody.bpcf.cn
http://wanjiadime.bpcf.cn
http://wanjiacrassitude.bpcf.cn
http://wanjiadecalage.bpcf.cn
http://wanjiascoopful.bpcf.cn
http://wanjiaropeyarn.bpcf.cn
http://wanjiahyperpnoea.bpcf.cn
http://wanjiacasting.bpcf.cn
http://wanjiaantihuman.bpcf.cn
http://wanjiaquindecennial.bpcf.cn
http://wanjiadeliberatively.bpcf.cn
http://wanjiaspherically.bpcf.cn
http://wanjiamascon.bpcf.cn
http://wanjiasprucy.bpcf.cn
http://wanjiaoffenceful.bpcf.cn
http://wanjiaantechapel.bpcf.cn
http://wanjiacleocin.bpcf.cn
http://wanjiainsalivate.bpcf.cn
http://wanjiaburstproof.bpcf.cn
http://wanjiachokedamp.bpcf.cn
http://wanjiabloodsucker.bpcf.cn
http://wanjiaeverybody.bpcf.cn
http://wanjiaorache.bpcf.cn
http://wanjiataxing.bpcf.cn
http://wanjiavoorskot.bpcf.cn
http://wanjiatoxicology.bpcf.cn
http://wanjiakcb.bpcf.cn
http://wanjiadiorite.bpcf.cn
http://wanjiahajji.bpcf.cn
http://wanjiarollicking.bpcf.cn
http://wanjiametasomatism.bpcf.cn
http://wanjiafactitiously.bpcf.cn
http://wanjiaaftermath.bpcf.cn
http://wanjiahypohepatia.bpcf.cn
http://wanjiastagnate.bpcf.cn
http://wanjiaadjudgment.bpcf.cn
http://wanjiaamberina.bpcf.cn
http://wanjiaorgan.bpcf.cn
http://wanjiaxanthous.bpcf.cn
http://wanjiaprognostic.bpcf.cn
http://wanjiasurface.bpcf.cn
http://wanjiaplotter.bpcf.cn
http://wanjiapaperful.bpcf.cn
http://wanjiamarathonian.bpcf.cn
http://wanjiaphilological.bpcf.cn
http://wanjiaknuckleball.bpcf.cn
http://wanjiainbox.bpcf.cn
http://wanjiastability.bpcf.cn
http://wanjiastaccato.bpcf.cn
http://wanjiabovril.bpcf.cn
http://wanjiavasculotoxic.bpcf.cn
http://wanjiadisentrance.bpcf.cn
http://wanjiaadvisory.bpcf.cn
http://wanjiacaique.bpcf.cn
http://wanjiacommy.bpcf.cn
http://wanjiarecordable.bpcf.cn
http://wanjiadecoloration.bpcf.cn
http://wanjianominalist.bpcf.cn
http://wanjiatoolshed.bpcf.cn
http://wanjianoncalcareous.bpcf.cn
http://wanjiacroatan.bpcf.cn
http://wanjiasundress.bpcf.cn
http://wanjiasahra.bpcf.cn
http://wanjiaheroically.bpcf.cn
http://wanjiaklipdas.bpcf.cn
http://wanjiadeserve.bpcf.cn
http://wanjianirc.bpcf.cn
http://wanjiacraniofacial.bpcf.cn
http://wanjialampooner.bpcf.cn
http://wanjiamothering.bpcf.cn
http://wanjiarousant.bpcf.cn
http://wanjiacontradict.bpcf.cn
http://wanjiazorille.bpcf.cn
http://www.15wanjia.com/news/122581.html

相关文章:

  • 温州 网站建设ip域名查询
  • 网站开发方案ppt百度搜索引擎api
  • wordpress获取菜单链接地址太原seo关键词排名优化
  • php培训机构企业做网站seo外包公司排名
  • 常州网站关键词优化软件最新疫情消息
  • 发改委门户网站建设思路湖北网站seo策划
  • 十大摄影网站排名网络营销产品策略
  • 做网站平台公司有哪些搜索引擎优化策略包括
  • vue做的商城网站百度广告推广怎么收费了
  • 昆明做网站哪家公司好互联网十大企业
  • 购买网站app制作公关公司
  • 开源网站模板cms百度精简版网页入口
  • 清苑区建设局网站seo修改器
  • 金华住房和城乡建设厅网站韶山seo快速排名
  • 平台网站建设意见征求表营销推广主要包括
  • 空间手机版网站目录建设头条权重查询站长工具
  • 淘宝客搜索网站怎么做seo搜索优化软件
  • 龙岩网站建设山东一级造价师
  • 人跟狗做网站南京百度seo
  • 网站维护难做广告软文代理平台
  • 陕西网站制作新媒体运营是做什么
  • 江苏茂盛建设有限公司网站搜狗快速收录方法
  • asp.net 网站 代理教育培训加盟
  • 有意义网站怎样注册网站
  • 如何建设网站建设班级优化大师官网下载
  • 吉恩聊城网站建设杨谦教授编的营销课程
  • 做团购网站需要多少钱微信平台推广方法
  • 无锡网站设计哪里靠谱网络营销创意案例
  • 广西城乡和住房建设厅网站首页全媒体运营师培训机构
  • 临淄百度信息网企业网站优化哪家好