机器学习周报(RNN的梯度消失和LSTM缓解梯度消失公式推导)

摘要

在深度学习领域,循环神经网络(Recurrent Neural Network, RNN)被广泛应用于处理序列数据,特别是在自然语言处理、时间序列预测等任务中。然而,传统的RNN在长序列数据学习过程中容易出现梯度消失和梯度爆炸问题,使得模型难以捕捉长时间依赖性。梯度消失问题源于RNN的反向传播算法中,多次矩阵相乘导致梯度指数级衰减,从而影响模型性能。为解决这一问题,长短期记忆网络(Long Short-Term Memory, LSTM)应运而生。LSTM通过设计特殊的门结构(输入门、遗忘门和输出门)以及引入细胞状态的传播,有效缓解了梯度消失现象。本文推导了RNN梯度消失的数学公式,并详细说明了LSTM如何利用门结构保持梯度稳定性,从而捕捉长时间依赖。

Abstract

Recurrent Neural Networks (RNNs) are widely used in deep learning for handling sequential data, particularly in tasks such as natural language processing and time series forecasting. However, traditional RNNs often encounter the vanishing and exploding gradient problem when learning from long sequences, which hinders their ability to capture long-term dependencies. The vanishing gradient problem arises in RNNs due to multiple matrix multiplications during backpropagation, causing exponential decay of gradients and impacting model performance. To address this issue, Long Short-Term Memory (LSTM) networks were developed. LSTM alleviates gradient vanishing by introducing specially designed gate structures—input gate, forget gate, and output gate—along with a cell state that propagates through time. This paper derives the mathematical basis for the vanishing gradient in RNNs and explains how LSTM leverages gate structures to maintain gradient stability, enabling the model to capture long-term dependencies effectively.

1 RNN的梯度消失问题

在这里插入图片描述

  • RNN的缺点

当序列太长时,容易产生梯度消失,参数更新只能捕捉到局部以来关系,没法再捕捉序列之间长期的关联或依赖关系。

如图为RNN连接,输入x,输出o(简单线性输出),权重w,s为生成状态。

在这里插入图片描述

根据前向传播可得:

在这里插入图片描述
假设使用平方误差作为损失函数,对单个时间点进行求梯度,假设再t=3时刻,损失函数为 L 3 = 1 2 ( Y 3 − O 3 ) 2 L_3=\frac{1}{2}(Y_3-O_3)^2 L3=21(Y3O3)2,然后根据网络参数Wx,Ws,Wo,b1,b2等求梯度。

  • W o W_o Wo求梯度得:

在这里插入图片描述

  • W x W_x Wx求梯度得:

在这里插入图片描述

具体求解过程:首先,所求目标为 L 3 L_3 L3 W x W_x Wx的偏导,通过链式法则进行展开。对比前向传播公式图可知, O 3 O_3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值