当前位置:网站首页>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)
边栏推荐
- Durham High Lord (classic DP)
- Solve the brick stacking problem (DP)
- 基于 MinIO 对象存储保障 Rancher 数据
- 进制及数的表示 2
- Intermediate soft test (system integration project management engineer) high frequency test site
- C language - data storage
- Introduction to seven kinds of polling (practice link attached)
- HSETNX KEY_NAME FIELD VALUE 用法
- 一碰撞就自燃,谁来关心电池安全?上汽通用有话说
- Raspberry pie CM4 -- using metartc3.0 to integrate ffmpeg to realize webrtc push-pull streaming
猜你喜欢

读取json配置文件,实现数据驱动测试

The results of the second quarter online moving people selection of "China Internet · moving 2022" were announced

Advanced notes (Part 2)

基于 MinIO 对象存储保障 Rancher 数据
![[C language] string reverse order implementation (recursion and iteration)](/img/c3/02d0a72f6026df8a67669293e55ef2.png)
[C language] string reverse order implementation (recursion and iteration)

Basic knowledge of communication network 01

83.(cesium之家)cesium示例如何运行

树行表达方式
![[C language] random number generation and `include < time. H > 'learning](/img/bb/3e47bf2e3b25653d9048884d65cda3.png)
[C language] random number generation and `include < time. H > 'learning

NEIL: Extracting Visual Knowledge from Web Data
随机推荐
LeetCode-297-二叉树的序列化与反序列化
What is the variance?
Implementation of strcat in C language
C language - control statement
Find the memory occupied by the structure
Solve the cookie splitting problem (DP)
Using Lex (Flex) to generate lexical analyzer of PL language
Implementation of memmove in C language
2、 Relationship between software operation and memory
2. Floating point number, the difference between float and double in C language and how to choose them
Basic mathematical knowledge (update)
Use of strtok and strError
Cdga | how can the industrial Internet industry do a good job in data governance?
Storage of C language data in memory (1)
Multi-Modal Knowledge Graph Construction and Application: A Survey
[C language] step jumping problem [recursion]
Related concepts of multitasking programming
Solve the brick stacking problem (DP)
Implementation of memcpy in C language
WPF -- implement websocket server