LSTM的计算公式及理解

一. 入门

对于深度学习和LSTM的新手,可参考零基础入门深度学习系列文章,这些文章用通俗易懂的方式介绍了深度学习的基础知识,包括前向传播和反向传播的数学推导等,适合入门深度学习和LSTM。

零基础入门深度学习(1) - 感知器
零基础入门深度学习(2) - 线性单元和梯度下降
零基础入门深度学习(3) - 神经网络和反向传播算法
零基础入门深度学习(4) - 卷积神经网络
零基础入门深度学习(5) - 循环神经网络
零基础入门深度学习(6) - 长短时记忆网络(LSTM)
零基础入门深度学习(7) - 递归神经网络

二. 计算过程和公式

LSTM的详细计算过程的解释可参考:LSTM以及三重门,遗忘门,输入门,输出门。该文章把下图的计算过程一步一步拆开来解释。

LSTM解决远程遗忘问题的关键是细胞状态cell,上图的上方的水平线贯穿运行。这条水平线形象地说明:上一时刻的细胞状态$c_{t-1}$,先遗忘掉一些不重要的信息(怎么遗忘由$f_t$决定),然后从当前时刻的输入中添加一些信息(怎么添加由$i_t$和$C'_t$决定)。细胞状态类似于传送带。直接在整个链上运行,只有一些少量的线性交互。信息在上面流传保持不变会很容易。 

The major innovation of LSTM is its memory cell ct which essentially acts as an accumulator of the state information. The cell is accessed, written and cleared by several self-parameterized controlling gates. Every time a new input comes, its information will be accumulated to the cell if the input gate $i_t$ is activated. Also, the past cell status $c_{t-1}$ could be “forgotten” in this process if the forget gate $f_t$ is on. Whether the latest cell output $c_t$ will be propagated to the final state $h_t$ is further controlled by the output gate $o_t$. One advantage of using the memory cell and gates to control information flow is that the gradient will be trapped in the cell (also known as constant error carousels) and be prevented from vanishing too quickly, which is a critical problem for the vanilla RNN model.

LSTM的计算公式:

三. LSTM的变体

peephole LSTM:在计算遗忘门、输入门、输出门时要考虑cell的状态。

耦合遗忘门和输入门:遗忘率和输入率总和为1。

GRU

GRU对LSTM做了两个大改动:

  1. 将输入门、遗忘门、输出门变为两个门:更新门$z_t$(Update Gate)和重置门$r_t$(Reset Gate)
  2. 将单元状态与输出合并为一个状态:$h_t$

【参考资料】

[译] 理解 LSTM(Long Short-Term Memory, LSTM) 网络

理解LSTM网络

原文地址:https://www.cnblogs.com/picassooo/p/12527984.html