![](https://img-blog.csdnimg.cn/img_convert/221e424a7fa59e2983af5370e4221ebe.png)
![](https://img-blog.csdnimg.cn/img_convert/fcc293ca1fa5dddc4975d7600132a81e.png)
Xt = [5,3,100] 第一个参数为单词数 第二个参数为句子数(批量)第三个参书每个单词用多少维的向量表示
Ht 会根据Xt和 H0 进行自我更新
![](https://img-blog.csdnimg.cn/img_convert/76fdb0443ce344b782b93af324697b92.png)
Whh 表示上一层的h和这一层h之间权重 Wxh表示输入x和记忆单元h之间的权重
![](https://img-blog.csdnimg.cn/img_convert/07237ec6c42c67661765014c9a2d00c2.png)
H是所有mermory 的累加 而每一层的out是不变的
![](https://img-blog.csdnimg.cn/img_convert/60a2783d6c07d169a8ad86a8eea84ead.png)
RNN类 可以一次投喂给网络 RNNCELL需要多次投喂 每一次投喂一个句子 不能进行自我更新
![](https://img-blog.csdnimg.cn/img_convert/30b547b0143c037b9ffbdab618cef1d5.png)
![](https://img-blog.csdnimg.cn/img_convert/cf48afb0752cd72d66f649f3289d4489.png)
梯度爆炸
![](https://img-blog.csdnimg.cn/img_convert/a9743fc14484dfc242f9f836664402d5.png)
![](https://img-blog.csdnimg.cn/img_convert/28b22b1b26832f903f5faff85a429335.png)
梯度消失
![](https://img-blog.csdnimg.cn/img_convert/6c62a5cda38f64dacf50f2de64c8c757.png)
LSTM 原理讲解
![](https://img-blog.csdnimg.cn/img_convert/5cf8a74f8f2a1b8b1e9a6faaca5d5a97.png)
![](https://img-blog.csdnimg.cn/img_convert/9c55b2245dcbe1deff3038c01b28d0aa.png)
![](https://img-blog.csdnimg.cn/img_convert/b88d671fed1a950ce7c8ba896f984825.png)
![](https://img-blog.csdnimg.cn/img_convert/cbcb8fedb67ad0b547b30521dc6bf9f8.png)
![](https://img-blog.csdnimg.cn/img_convert/3c5ab7b68ef0810dc2c3b72f68218e01.png)
![](https://img-blog.csdnimg.cn/img_convert/0d18cc22ac9f607c5522d73538a29287.png)
![](https://img-blog.csdnimg.cn/img_convert/9778bb7c212895403311056219b7d3e6.png)
![](https://img-blog.csdnimg.cn/img_convert/c3229c800ab426ecd0e9fb5ce9f07b6e.png)
梯度中含有加号不会出现连成的形式 防止梯度消失
代码实现
![](https://img-blog.csdnimg.cn/img_convert/a5d1c83fe88ee4232cdfa389a70ef6cf.png)
![](https://img-blog.csdnimg.cn/img_convert/936a585fd0afc1579d58c0e91563a8ff.png)
![](https://img-blog.csdnimg.cn/img_convert/2cbd0f3bb704c5ba959f4497ee93c1b6.png)
![](https://img-blog.csdnimg.cn/img_convert/72261aaf1240e10b66a848dc22d17c86.png)
LSTMcelll
![](https://img-blog.csdnimg.cn/img_convert/bcb7ab5625a90ff6f718755820b5c489.png)