RNN是

Vanilla RNN

- $t$——time step
- $X$——input
- $h$——hidden state
- length of $X$ —size/dimension of input
- length of $h$ — no. of hidden units. Note that different libraries call them differently, but they mean the same:
- Keras —
state_size,units - PyTorch —
hidden_size - TensorFlow —
num_units
- Keras —
LSTM
Overview
下面两张图是LSTM中一个cell的内部结构。


上图中各个符号的含义:

Neural Network Layer表示里面具有需要学习的参数。Pointwise Operation表示单纯的向量操作,比如vector addition。需要仔细观察的是,在上图中,有一个tanh函数属于Neural Network Layer,而另一个tanh函数属于Pointwise Operation,区别可以在Input Gate Layer和Output Gate Layer部分的数学公式知晓。
LSTM一共有3个gate来控制cell state。
Step 1: Forget Gate Layer

Step 2: Input Gate Layer

接下来对Cell State进行更新:

Step 3: Output Gate Layer

GRU(Gated Recurrent Unit )

