当前位置:网站首页>GRU神经网络
GRU神经网络
2022-07-28 18:18:00 【李峻枫】
RNN的局限性
在处理时序数据时候,RNN是一种十分简单的方法,但是它并不完美。它会记住太多的信息。
回忆一下能够状态函数 H t H_t Ht,它对每个进入的 X t X_t Xt都记录了。然而实际上并不需要完全记住这么多信息,就像一句话中的“的”之类的词就是意义不大的。记录了这些无用的信息反而会对预测产生误导。
此外还存在的一种特殊情况:概念漂移,随着时间的推移数据分布发送了变化。
面对这种情况,过去记录的状态信息可能不管用了,而且会产生误导,需要将其遗忘。
GRU神经网络
针对上述两种缺陷,GRU神经网络应运而生,它通过增设两个“门”,来实现的。
重置门
通过这个门就可以有效的解决概念漂移的问题。
R t = Θ ( X t ⋅ W x r + H t − 1 ⋅ W h r + b r ) R_t=\Theta\left( X_t\cdot W_{xr} + H_{t-1}\cdot W_{hr} + b_r \right) Rt=Θ(Xt⋅Wxr+Ht−1⋅Whr+br)
R t R_t Rt与 H t − 1 H_{t-1} Ht−1对应元素相乘,并于 X t X_t Xt对于元素相加,就得到了候选状态 H t ′ H'_t Ht′。
考虑两种极端情况:
- R t R_t Rt中全部是 1 1 1,也就是说记住之前全部的历史信息$H_{t-1}。
- R t R_t Rt中全部是 0 0 0,也就是说遗忘掉全部的历史信息 H t − 1 H_{t-1} Ht−1,即重置。
W , B W,B W,B是需要学习的权重,它们负责判断在哪些状态下需要遗忘(重置)说明。
更新门
在重置门中,产生了有关候选状态 H t ′ H'_t Ht′,它还需要经过更新门才能变为真正的状态 H t H_t Ht。
Z t = Θ ( X t ⋅ W x z + H t − 1 ⋅ W h z + b z ) H t = Z t ∗ H t − 1 + ( 1 − Z t ) ∗ H t ′ Z_t=\Theta\left( X_t\cdot W_{xz} + H_{t-1}\cdot W_{hz} + b_z \right) \newline H_t =Z_t*H_{t-1}+\left( 1 - Z_t\right)*H'_t Zt=Θ(Xt⋅Wxz+Ht−1⋅Whz+bz)Ht=Zt∗Ht−1+(1−Zt)∗Ht′
- 此处的
*表示对应元素相乘
通过这个公式,就可以看出来, Z t Z_t Zt就是觉得当前状态更新多少到 H t H_t Ht中。
代码实现
pytorch中有提供GRU神经网络层,直接调用即可。
nn.GRU(vocab_size , hidden_size)
边栏推荐
- 7. Functions of C language, function definitions and the order of function calls, how to declare functions, prime examples, formal parameters and arguments, and how to write a function well
- 私有化部署的即时通讯平台,为企业移动业务安全保驾护航
- Introduction to seven kinds of polling (practice link attached)
- 【实验分享】CCIE—BGP反射器实验
- JVM(二十四) -- 性能监控与调优(五) -- 分析GC日志
- 弹出模态框
- flask_ Mail source code error
- Implementation of strcat in C language
- 最大交换[贪心思想&单调栈实现]
- Raspberry pie 3b ffmpeg RTMP streaming
猜你喜欢

2. Floating point number, the difference between float and double in C language and how to choose them

Why is customer support important to SaaS?

Rand function generates pseudo-random numbers

LeetCode-297-二叉树的序列化与反序列化

为什么客户支持对SaaS公司很重要?

Related concepts of multitasking programming
![[C language] print pattern summary](/img/48/d8ff17453e810fcd9269f56eda4d47.png)
[C language] print pattern summary

Hebei: stabilizing grain and expanding beans to help grain and oil production improve quality and efficiency

How to use pycharm to quickly create a flask project

C+ + core programming
随机推荐
Digital filter design matlab
CM4 development cross compilation tool chain production
Raspberry pie 4B parsing PWM
zfoo增加类似于mydog的路由
Use of strtok and strError
C语言数据 3(1)
[experiment sharing] CCIE BGP reflector experiment
熊市下PLATO如何通过Elephant Swap,获得溢价收益?
Solve flask integration_ Error reporting in restplus
1、 Relationship among CPU, memory and hard disk
JVM(二十四) -- 性能监控与调优(五) -- 分析GC日志
[C language] shutdown game [loop and switch statement]
[C language] step jumping problem [recursion]
4. Const and difine and the problem of initializing arrays with const and define
[C language] Gobang game [array and function]
C language array and bubble sort
Stories of Party members | Li qingai uses cartoons to drive farmers to increase income and become rich
Sequential linear table - practice in class
Multi-Modal Knowledge Graph Construction and Application: A Survey
Practice of real-time push demo of three web messages: long polling, iframe and SSE