当前位置:网站首页>深度理解RNN的梯度消失和LSTM为什么能解决梯度消失
深度理解RNN的梯度消失和LSTM为什么能解决梯度消失
2022-06-21 05:57:00 【前行_的路上】
一、RNN的梯度消失有什么不同之处
先说结论:RNN的梯度等于近距离梯度与远距离梯度的和,RNN的梯度消失是远距离梯度的消失,而近距离梯度不会消失,同时总的梯度不会消失,从而导致总的梯度由近距离梯度占主导。
提到梯度消失,你肯定会说是因为网络层次太深,导致导数连乘项太多,所以梯度很小。这种回答适用于深度神经网络,但不适用于RNN。
因为RNN的梯度是一个和!!而且RNN的是共享一套参数的!
但我们在理解RNN的时候,经常喜欢把RNN按时间序列展开,可能会误解RNN是多套参数的,但其实是共用一套参数。

假设时间序列为3,将RNN展开就如上图所示,每一个时刻的隐状态和输出分别如下式:

假设我们现在处理的任务只需要用t=3时刻的输出去训练模型:
l
对Wx,Ws,Wo求偏导:

根据公式可以看出:时间序列越长,梯度连乘就越多,这就导致远距离梯度越小
二、LSTM为什么能解决RNN的梯度消失问题
LSTM有三个门:分别是遗忘门、输入门和输出门。
遗忘门:![f(t) = \sigma (W_{f}[h_{t-1}, x_{t}]+b_{f})](http://img.inotgo.com/imagesLocal/202206/21/202206210556468067_7.gif)
输入门:![i(t) = \sigma(W_i[h_{t-1}, x_t]+b_i))](http://img.inotgo.com/imagesLocal/202206/21/202206210556468067_0.gif)
输出门:![o(t) = \sigma(W_o[h_{t-1}, x_t]+b_o)](http://img.inotgo.com/imagesLocal/202206/21/202206210556468067_3.gif)
细胞状态:![c_t = f(t)\odot{c_{t-1}} + i(t)\odot tanh(W_c[h_{t-1}, x_t]+b_c)](http://img.inotgo.com/imagesLocal/202206/21/202206210556468067_4.gif)
隐状态:
在前面的文章中,我们知道RNN梯度消失或梯度爆炸的原因是由于
,如果我们想办法将这一大坨去掉,就可以解决梯度问题了,而LSTM通过门机制解决了这个问题:
,
我们知道,f(t)和o(t)是用sigmoid函数激励的,而sigmoid函数长这样:

经过sigmoid函数映射之后的值非常容易趋近于0或者1,因此
的这种一大坨问题就可以顺利解决。即当门为1时,梯度可以顺畅的在LSTM中传播,当门为0时,上一时刻的信息对当前时刻没有影响,也就没必要传递梯度回去更新参数了。
边栏推荐
- 应用在电视触摸屏中的十四通道智能触摸芯片
- Things to think about before using mysqldump
- You have an error in your SQL syntax; check the manual that corresponds to your MYSQL server
- 【数据挖掘】期末复习 第五章
- 基于注意力的seq2seq模型
- Connection refused : no futher information : localhost/127.0.0.1:6379
- sqli-labs25
- DDD 实践手册(4. Aggregate — 聚合)
- Fluorite Cloud Application
- tf.compat.v1.MetaGraphDef
猜你喜欢

代码生成器文件运行出错:The server time zone value ‘�й���ʱ��‘ is unrecognized or represents more than one time

sqli-labs25

一次Namenode的RPC延迟故障排查引发的深入思考

成立时间用了时间插件,但在网页上修改参数的时候,如果未修改时间第一次保存会报错,第二次才行

Microbial ecological sequencing analysis -- CCA analysis

Basic operation of binary sort tree

Copy the code generated by the code generator to the idea. How to solve the error reported by the web address after running

微生物生态数据分析——冗余分析

模块 14 - 15:网络应用通信考试

对网页 ‘’为所欲为‘’ 之手动实现 csdn深色模式?
随机推荐
计组必刷题:存储系统(已完结,附详细解析)
NFT platform track dark horse takes advantage of the situation
应用在LED植物照明中的LED照明灯
内卷大厂系列《LRU 缓存淘汰算法》
UVC sterilization lamp with integrated sterilization, deodorization and odor removal
Discussion on the American ess audio DAC decoder chip es9023
tf.compat.v1.pad
sqli-labs23
Analog ambient light sensor chip used in backlight display of electronic products
力扣------移除字母异位词后的结果数组
The database is 8.0 students. In this place, add this paragraph? useSSL=false&serverTimezone=GMT%2B8&characterEncoding=utf8
高速缓存Cache(计算机组成原理笔记)
应用在洗衣机触摸屏中的触摸芯片
[mysql] MySQL file structure, page and line records
牛客-TOP101-BM25
Refine business details
Improve the determination of the required items of business details. When the error information is echoed according to the returned status code, the echoed information is inconsistent with the expecta
Leetcode刷題 ——— (4)字符串中的第一個唯一字符
Account1 is not in the sudoers file. The matter will be reported.
sqli-labs26