可视化资源

循环神经网络与门控机制

RNN 的展开形式,以及 LSTM / GRU 的门控结构示意。

RNN 的时间展开

RNN 的时间展开
同一个 RNN 单元在时间维度上展开,对应一个深度等于序列长度的网络。
来源:Chris Olah — Understanding LSTM Networks

LSTM 单元

LSTM 引入三个门(遗忘门、输入门、输出门)和一个独立的细胞状态,缓解长依赖梯度问题。

LSTM 链式结构
LSTM 单元的整体结构:细胞状态(上方水平线)受三个门控调控。
来源:Chris Olah — Understanding LSTM Networks
遗忘门
遗忘门:决定丢弃多少旧细胞状态。
来源:Chris Olah — Understanding LSTM Networks
输入门
输入门:决定写入哪些新信息。
来源:Chris Olah — Understanding LSTM Networks
细胞状态更新
细胞状态更新:旧状态 × 遗忘门 + 新信息 × 输入门。
来源:Chris Olah — Understanding LSTM Networks
输出门
输出门:决定输出哪部分细胞状态。
来源:Chris Olah — Understanding LSTM Networks

GRU 单元

GRU 把 LSTM 的三个门简化为两个(更新门 + 重置门),合并细胞状态与隐藏状态。

GRU 单元
GRU 单元结构。
来源:Chris Olah — Understanding LSTM Networks

图片来源:Chris Olah — Understanding LSTM Networks(CC-BY 许可,已注明出处)。
TODO:如需镜像至本站,下载至 assets/viz/ 并替换 src

字符级 RNN 生成

字符级 RNN 生成示例
RNN 按字符逐步生成文本:每一步的输入是上一步的输出。
来源:Andrej Karpathy — The Unreasonable Effectiveness of Recurrent Neural Networks

图片来源:Andrej Karpathy — The Unreasonable Effectiveness of Recurrent Neural Networks