1. RNN(Recurrent Neural Network)

image-extv.png

相关公式:

a^{<t>} = \tanh(W_a \cdot [a^{<t-1>}, x^{<t>} ] + b_a)

\hat{y}^{<t>} = \sigma(W_y \cdot a^{<t>} + b_y)

2. GRU(Gate Recurrent Unit)

2.1 GRU(simplified)

image-egiq.png

更新门(Update Gate):更新门决定了多少过去的信息需要被遗忘,以及多少新的信息需要被加入。更新门的公式为:

\gamma_u^{<t>} = \sigma(W_u \cdot [a^{<t-1>}, x^{<t>} ] + b_u)

候选隐藏状态(Candidate Hidden State):候选隐藏状态是用于更新隐藏状态的候选值。候选隐藏状态的公式为:

\tilde{c}^{<t>} = \tanh(W_c \cdot [a^{<t-1>}, x^{<t>} ] + b_c)

隐藏状态更新:隐藏状态的更新公式为:

c^{<t>} = \gamma_u^{<t>} \cdot \tilde{c}^{<t>} + (1 - \gamma_u^{<t>}) \cdot c^{<t-1>}

输出计算:输出计算的公式与 RNN 相同:

y^{<t>} = \sigma(W_y \cdot a^{<t>} + b_y)

2.2 GRU(full)

image-kojz.png

注意完全版的GRU多了一个重置门,这影响了候选隐藏状态的计算

重置门(Reset Gate):重置门决定了多少过去的信息需要被保留。重置门的公式为:

\gamma_r^{<t>} = \sigma(W_r \cdot [c^{<t-1>}, x^{<t>} ] + b_r)

候选隐藏状态(Candidate Hidden State):候选隐藏状态是用于更新隐藏状态的候选值。候选隐藏状态的公式为:

\tilde{c}^{<t>} = \tanh(W_c \cdot [\gamma_r^{<t>} \cdot a^{<t-1>}, x^{<t>} ] + b_c)

3. LSTM(Long Short-Term Memory)

image-tbnz.png

长短期记忆网络(Long Short-Term Memory,LSTM)是 RNN 的一种变体,它通过引入门控机制来更好地处理长序列数据。LSTM 的公式如下:
遗忘门(Forget Gate):遗忘门决定了多少过去的信息需要被遗忘。遗忘门的公式为:

\gamma_f^{<t>} = \sigma(W_f \cdot [a^{<t-1>}, x^{<t>} ] + b_f)

输入门(Input Gate):输入门决定了多少新的信息需要被加入。输入门的公式为:

\gamma_i^{<t>} = \sigma(W_i \cdot [a^{<t-1>}, x^{<t>} ] + b_i)

候选细胞状态(Candidate Cell State):候选细胞状态是用于更新细胞状态的候选值。候选细胞状态的公式为:

\tilde{c}^{<t>} = \tanh(W_c \cdot [a^{<t-1>}, x^{<t>} ] + b_c)

细胞状态更新:细胞状态的更新公式为:

c^{<t>} = \gamma_f^{<t>} \cdot c^{<t-1>} + \gamma_i^{<t>} \cdot \tilde{c}^{<t>}

输出门(Output Gate):输出门决定了多少细胞状态的信息需要被输出。输出门的公式为:

\gamma_o^{<t>} = \sigma(W_o \cdot [a^{<t-1>}, x^{<t>} ] + b_o)

隐藏状态更新:隐藏状态的更新公式为:

a^{<t>} = \gamma_o^{<t>} \cdot \tanh(c^{<t>})

输出计算:输出计算的公式与 RNN 相同:

y^{<t>} = \sigma(W_y \cdot a^{<t>} + b_y)