myfnsymbols** ††‡‡§§‖∥¶¶

循环神经网络正则化

Wojciech Zaremba11111footnotetext: Work done while the author was in Google Brain.
New York University
woj.zaremba@gmail.com
&Ilya Sutskever, Oriol Vinyals
Google Brain
{ilyasu,vinyals}@google.com

摘要

我们提出了一种用于具有长短期记忆 (LSTM) 单元的循环神经网络 (RNN) 的简单正则化技术。 Dropout 是最成功的神经网络正则化技术,但它不适用于 RNN 和 LSTM。 在本文中,我们展示了如何正确地将 dropout 应用于 LSTM,并证明它可以大大减少各种任务的过度拟合。 这些任务包括语言建模、语音识别、图像字幕生成和机器翻译。

222作者在 Google Brain 期间完成的工作。

1简介

循环神经网络 (RNN) 是一种神经序列模型,在重要任务上实现了最先进的性能,包括语言建模 Mikolov (2012)、语音识别 Graves 等人 (2013) 和机器翻译 Kalchbrenner & Blunsom (2013) 众所周知,神经网络的成功应用需要良好的正则化。 不幸的是,前馈神经网络最强大的正则化方法 dropout Srivastava (2013) 并不适用于 RNN。 因此,RNN 的实际应用经常使用太小的模型,因为大的 RNN 往往会过度拟合。 现有的正则化方法对 RNN Graves (2013) 的改进相对较小。 在这项工作中,我们表明,正确使用 dropout 可以大大减少 LSTM 中的过度拟合,并针对三个不同的问题对其进行评估。

这项工作的代码可以在 https://github.com/wojzaremba/lstm 中找到。

2相关工作

Dropout Srivastava (2013) 是最近引入的一种正则化方法,在前馈神经网络中非常成功。 虽然许多工作以各种方式延长了辍学时间Wang & Manning (2013); Wan等人(2013),将其应用于RNN的研究相对较少。 关于这个主题的唯一论文是 Bayer 等人 (2013),他专注于“边缘化 dropout”Wang & Manning (2013),这是标准 dropout 的无噪声确定性近似。 Bayer 等人 (2013) 声称传统的 dropout 不适用于 RNN,因为重复会放大噪声,进而损害学习。 在这项工作中,我们表明可以通过将 dropout 应用于 RNN 连接的某个子集来解决这个问题。 因此,RNN 现在也可以从 dropout 中受益。

独立于我们的工作,Pham 等人 (2013) 开发了完​​全相同的 RNN 正则化方法并将其应用于手写识别。 我们重新发现了这种方法,并在广泛的问题上展示了强有力的实证结果。 将 dropout 应用于 LSTM 的其他工作是 Pachitariu & Sahani (2013)

RNN 有许多架构变体,它们在长期依赖问题上表现更好 Hochreiter & Schmidhuber (1997); Graves 等人 (2009); Cho 等人 (2014); Jaeger 等人 (2007); Koutník 等人 (2014); Sundermeyer 等人 (2012) 在这项工作中,我们展示了如何正确地将 dropout 应用于 LSTM(最常用的 RNN 变体);这种应用 dropout 的方式可能也适用于其他 RNN 架构。

在本文中,我们考虑以下任务:语言建模、语音识别和机器翻译。 语言建模是 RNN 取得实质性成功的第一个任务 Mikolov 等人 (2010; 2011); Pascanu 等人 (2013). RNN 也已成功用于语音识别 Robinson 等人 (1996); Graves 等人 (2013) 最近被应用于机器翻译,用于语言建模、重新排名或短语建模 Devlin 等人 (2014);卡尔奇布伦纳和布伦瑟姆 (2013); Cho 等人 (2014); Chow 等人 (1987); Mikolov 等人 (2013).

3 使用 LSTM 单元规范 RNN

在本节中,我们将描述深度 LSTM(第 3.1 节)。 接下来,我们展示如何对它们进行正则化(第3.2节),并解释为什么我们的正则化方案有效。

我们让下标表示时间步长,上标表示层。 我们所有的状态都是n维的。 htln 为时间步 tl 中的隐藏状态。此外,令Tn,m:nm为仿射变换(Wx+b对于某些Wb)。 为逐元素乘法,令 ht0 为时间步 k 处的输入词向量。我们使用激活 htL 来预测 yt,因为 L 是深度 LSTM 中的层数。

3.1 长短期记忆单元

RNN 动态可以使用从先前隐藏状态到当前隐藏状态的确定性转换来描述。 确定性状态转移是一个函数

RNN:htl1,ht1lhtl

对于经典 RNN,该函数由下式给出

htl=f(Tn,nhtl1+Tn,nht1l), where f{sigm,tanh}

LSTM 具有复杂的动态特性,使其能够轻松“记忆”更多时间步长的信息。 “长期”记忆存储在记忆单元ctln向量中。 尽管许多 LSTM 架构的连接结构和激活函数有所不同,但所有 LSTM 架构都具有显式记忆单元,用于长时间存储信息。 LSTM 可以决定覆盖记忆单元、检索它或保留它以供下一个时间步骤使用。 我们实验中使用的 LSTM 架构由以下方程给出 Graves 等人 (2013)

LSTM:htl1,ht1l,ct1lhtl,ctl
(ifog)=(sigmsigmsigmtanh)T2n,4n(htl1ht1l)
ctl=fct1l+ig
htl=otanh(ctl)

在这些等式中,sigmtanh 按元素应用。 1 说明了 LSTM 方程。

𝐜tCell×fForget gateht1lhtl1iInputgateht1lhtl1oOutputgateht1lhtl1gInputmodulationgate××𝐡tlht1lhtl1
图1: 本文使用的 LSTM 存储单元的图形表示(与 Graves (2013) 相比存在细微差别)。

3.2 带有 Dropout 的正则化

本文的主要贡献是一种将 dropout 应用于 LSTM 的方法,成功地减少了过度拟合。 主要思想是将 dropout 运算符仅应用于非循环连接(图2)。 下面的等式更准确地描述了它,其中 𝐃 是将其参数的随机子集设置为零的 dropout 运算符:

(ifog)=(sigmsigmsigmtanh)T2n,4n(𝐃(htl1)ht1l)
ctl=fct1l+ig
htl=otanh(ctl)
xt2xt1xtxt+1xt+2yt2yt1ytyt+1yt+2
图2: 正则化多层 RNN。 虚线箭头表示应用了dropout的连接,实线表示未应用dropout的连接。

我们的方法的工作原理如下。 丢失运算符会破坏单元所携带的信息,迫使它们更稳健地执行中间计算。 同时,我们不想删除单元中的所有信息。 尤其重要的是,这些单元要记住过去许多时间步发生的事件。 3 显示了在我们的 Dropout 实现中,信息如何从时间步 t2 发生的事件流向时间步 t+2 的预测。 我们可以看到信息被 dropout 算子准确地破坏了 L+1 次,并且这个数字与信息遍历的时间步数无关。 标准 dropout 会扰乱循环连接,这使得 LSTM 很难学会长时间存储信息。 通过不在循环连接上使用 dropout,LSTM 可以从 dropout 正则化中受益,而不会牺牲其宝贵的记忆能力。

xt2xt1xtxt+1xt+2yt2yt1ytyt+1yt+2
图3: 粗线显示了 LSTM 中信息流的典型路径。 该信息受到 dropout L+1 次的影响,其中 L 是网络深度。

4实验

我们展示了三个领域的结果:语言建模(第 4.1 节)、语音识别(第 4.2 节)、机器翻译(第 4.3 节)和图像标题生成(第 4.4 节)。

4.1 语言建模

我们在 Penn Tree Bank (PTB) 数据集 Marcus 等人 (1993) 上进行了词级预测实验,该数据集由 929k 个训练词、73 组成>k 个验证词和 82k 个测试词。 它的词汇表中有10k 个单词。 我们从 Tomas Mikolov 的网页333http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz 我们训练了两种大小的正则化 LSTM;它们被表示为中型 LSTM 和大型 LSTM。 两个 LSTM 都有两层,并展开 35 步骤。 我们将隐藏状态初始化为零。 然后,我们使用当前小批量的最终隐藏状态作为后续小批量的初始隐藏状态(连续的小批量顺序遍历训练集)。 每个小批量的大小为 20。

Model Validation set Test set
A single model
Pascanu et al. (2013) 107.5
Cheng et al. 100.0
non-regularized LSTM 120.7 114.5
Medium regularized LSTM 86.2 82.7
Large regularized LSTM 82.2 78.4
Model averaging
Mikolov (2012) 83.5
Cheng et al. 80.6
2 non-regularized LSTMs 100.4 96.1
5 non-regularized LSTMs 87.9 84.1
10 non-regularized LSTMs 83.5 80.0
2 medium regularized LSTMs 80.6 77.0
5 medium regularized LSTMs 76.7 73.3
10 medium regularized LSTMs 75.2 72.0
2 large regularized LSTMs 76.9 73.6
10 large regularized LSTMs 72.8 69.5
38 large regularized LSTMs 71.9 68.7
Model averaging with dynamic RNNs and n-gram models
Mikolov & Zweig (2012) 72.9
表格1: Penn Tree Bank 数据集上的词级困惑。

the meaning of life is that only if an end would be of the whole supplier. widespread rules are regarded as the companies of refuses to deliver. in balance of the nation ’s information and loan growth associated with the carrier thrifts are in the process of slowing the seed and commercial paper.

the meaning of life is nearly in the first several months before the government was addressing such a move as president and chief executive of the nation past from a national commitment to curb grounds. meanwhile the government invests overcapacity that criticism and in the outer reversal of small-town america.

图4: 一些有趣的样本来自一个以“生命的意义是”为条件的大型正则化模型。 我们已从允许的单词集中删除了“unk”、“N”、“$”。

中型 LSTM 每层有 650 个单元,其参数在 [0.05,0.05] 中统一初始化。 如前所述,我们在非循环连接上应用 50% dropout。 我们以 1 的学习率训练 39 纪元的 LSTM,在 6 纪元后,我们将其降低 1.2 倍每个纪元之后。 我们将梯度范数(按小批量大小标准化)裁剪为 5 在 NVIDIA K20 GPU 上训练该网络大约需要半天时间。

大型LSTM每层有1500个单元,其参数在[0.04,0.04]中统一初始化。 我们在非循环连接上应用 65% dropout。 我们以 1 的学习率训练 55 个时期的模型;在 14 个 epoch 后,我们开始在每个 epoch 后将学习率降低 1.15 倍。 我们在 10 Mikolov 等人 (2010) 处裁剪梯度范数(按小批量大小归一化)。 在 NVIDIA K20 GPU 上训练该网络需要一整天的时间。

为了进行比较,我们训练了一个非正则化网络。 我们优化了其参数以获得最佳的验证性能。 缺乏正则化有效地限制了网络的大小,迫使我们使用小型网络,因为较大的网络会过度拟合。 我们性能最好的非正则化 LSTM 有两个隐藏层,每层都有 200 个单元,其权重在 [0.1,0.1] 中统一初始化。 我们以 1 的学习率训练 4 个纪元,然后在每个纪元后将学习率降低 2 倍,总共13 训练纪元。 每个小批量的大小为 20,我们将网络展开 20 步骤。 在 NVIDIA K20 GPU 上训练该网络需要 2-3 小时。

1 将之前的结果与我们的 LSTM 进行了比较,图 4 显示了从单个大型正则化 LSTM 中抽取的样本。

4.2语音识别

深度神经网络用于声学建模已有半个多世纪的历史(参见 Bourlard & Morgan (1993) 的精彩评论)。 声学建模是将声学信号映射到单词序列的关键组成部分,因为它对 p(st|X) 进行建模,其中 st 是时间 tX是声学观察。 最近的研究表明,LSTM 在声学建模方面可以取得优异的性能Sak 等人 (2014),但相对较小的 LSTM(就其参数数量而言)很容易过度拟合训练集。 测量声学模型性能的一个有用指标是帧精度,它是在所有时间步 t 的每个 st 处测量的。一般来说,该指标与实际感兴趣的指标——字错误率(WER)相关。 由于计算 WER 涉及使用语言模型并针对声学模型的每次变化调整解码参数,因此我们决定在这些实验中重点关注帧准确性。 2显示dropout提高了LSTM的帧精度。 毫不奇怪,由于训练过程中添加的噪声,训练帧的准确性会下降,但正如 dropout 的常见情况一样,这会产生能够更好地泛化到未见过的数据的模型。 请注意,测试集比训练集更容易,因为它的准确性更高。 我们报告了 LSTM 在内部 Google 冰岛语音数据集上的性能,该数据集相对较小(93k 话语),因此过度拟合是一个非常令人担忧的问题。

Model Training set Validation set
Non-regularized LSTM 71.6 68.9
Regularized LSTM 69.4 70.5
表2: 冰岛语音数据集的帧级准确性。 训练集有 93k 个话语。

4.3 机器翻译

我们将机器翻译问题表述为语言建模任务,其中训练 LSTM 为源句子的正确翻译分配高概率。 因此,LSTM 接受源句子及其翻译 Sutskever 等人 (2014) 的串联训练(另请参见 Cho 等人 (2014))。 我们通过使用波束大小为 12 的简单波束搜索来近似最可能的单词序列来计算翻译。 我们在 WMT’14 英语到法语数据集上运行了 LSTM,该数据集是来自 Schwenk (2014) 的“选定”子集,其中包含 3.4 亿法语单词和 3.04 亿英语单词。 我们的 LSTM 有 4 个隐藏层,其层和词嵌入都有 1000 个单元。 其英语词汇有16万个单词,法语词汇有8万个单词。 最佳退出概率为 0.2。 3显示了在有和没有dropout的情况下训练的LSTM的性能。 虽然我们的 LSTM 没有击败基于短语的 LIUM SMT 系统 Schwenk 等人 (2011),但我们的结果表明 dropout 提高了 LSTM 的翻译性能。

Model Test perplexity Test BLEU score
Non-regularized LSTM 5.8 25.9
Regularized LSTM 5.0 29.03
LIUM system 33.30
表3: 英语到法语翻译任务的结果。

4.4 图像标题生成

我们将 dropout 变体应用于 Vinyals 等人 (2014) 的图像标题生成模型。 图像标题生成类似于 Sutskever 等人 (2014) 的序列到序列模型,但其中输入图像通过高精度预训练卷积神经网络映射到向量上(Szegedy 等人, 2014),使用单层 LSTM 转换为标题(有关架构的详细信息,请参阅 Vinyals 等人 (2014))。 我们在 LSTM 上测试我们的 dropout 方案,因为卷积神经网络没有在图像描述数据集上进行训练,因为它并不大(MSCOCO (Lin 等人, 2014))。

我们的结果总结在下表4中。 简而言之,相对于不使用 dropout,dropout 有帮助,但使用集成消除了 dropout 所获得的收益。 因此,在这种情况下,dropout 的主要作用是产生一个与集成一样好的单一模型,考虑到技术的简单性,这是一个合理的改进。

Model Test perplexity Test BLEU score
Non-regularized model 8.47 23.5
Regularized model 7.99 24.3
10 non-regularized models 7.5 24.4
表 4: 图像标题生成任务的结果。

5结论

我们提出了一种将 dropout 应用于 LSTM 的简单方法,该方法可以在不同领域的多个问题上大幅提高性能。 我们的工作使 dropout 对于 RNN 很有用,我们的结果表明,我们实施 dropout 可以提高各种应用程序的性能。

6致谢

我们要感谢托马斯·米科洛夫 (Tomas Mikolov) 对本文第一版提出的有用评论。

参考

  • Bayer et al. (2013) Bayer, Justin, Osendorfer, Christian, Chen, Nutan, Urban, Sebastian, and van der Smagt, Patrick. On fast dropout and its applicability to recurrent networks. arXiv preprint arXiv:1311.0701, 2013.
  • Bourlard & Morgan (1993) Bourlard, H. and Morgan, N. Connectionist Speech Recognition: A Hybrid Approach. Kluwer Academic Publishers, 1993.
  • (3) Cheng, Wei-Chen, Kok, Stanley, Pham, Hoai Vu, Chieu, Hai Leong, and Chai, Kian Ming A. Language modeling with sum-product networks.
  • Cho et al. (2014) Cho, Kyunghyun, van Merrienboer, Bart, Gulcehre, Caglar, Bougares, Fethi, Schwenk, Holger, and Bengio, Yoshua. Learning phrase representations using rnn encoder-decoder for statistical machine translation. arXiv preprint arXiv:1406.1078, 2014.
  • Chow et al. (1987) Chow, Y, Dunham, M, Kimball, O, Krasner, M, Kubala, G, Makhoul, J, Price, P, Roucos, S, and Schwartz, R. Byblos: The bbn continuous speech recognition system. In Acoustics, Speech, and Signal Processing, IEEE International Conference on ICASSP’87., volume 12, pp. 89–92. IEEE, 1987.
  • Devlin et al. (2014) Devlin, J., Zbib, R., Huang, Z., Lamar, T., Schwartz, R., and Makhoul, J. Fast and robust neural network joint models for statistical machine translation. In ACL, 2014.
  • Graves (2013) Graves, Alex. Generating sequences with recurrent neural networks. arXiv preprint arXiv:1308.0850, 2013.
  • Graves et al. (2009) Graves, Alex, Liwicki, Marcus, Fernández, Santiago, Bertolami, Roman, Bunke, Horst, and Schmidhuber, Jürgen. A novel connectionist system for unconstrained handwriting recognition. Pattern Analysis and Machine Intelligence, IEEE Transactions on, 31(5):855–868, 2009.
  • Graves et al. (2013) Graves, Alex, Mohamed, Abdel-rahman, and Hinton, Geoffrey. Speech recognition with deep recurrent neural networks. In Acoustics, Speech and Signal Processing (ICASSP), 2013 IEEE International Conference on, pp. 6645–6649. IEEE, 2013.
  • Hochreiter & Schmidhuber (1997) Hochreiter, Sepp and Schmidhuber, Jürgen. Long short-term memory. Neural computation, 9(8):1735–1780, 1997.
  • Jaeger et al. (2007) Jaeger, Herbert, Lukoševičius, Mantas, Popovici, Dan, and Siewert, Udo. Optimization and applications of echo state networks with leaky-integrator neurons. Neural Networks, 20(3):335–352, 2007.
  • Kalchbrenner & Blunsom (2013) Kalchbrenner, N. and Blunsom, P. Recurrent continuous translation models. In EMNLP, 2013.
  • Koutník et al. (2014) Koutník, Jan, Greff, Klaus, Gomez, Faustino, and Schmidhuber, Jürgen. A clockwork rnn. arXiv preprint arXiv:1402.3511, 2014.
  • Lin et al. (2014) Lin, Tsung-Yi, Maire, Michael, Belongie, Serge, Hays, James, Perona, Pietro, Ramanan, Deva, Dollár, Piotr, and Zitnick, C Lawrence. Microsoft coco: Common objects in context. arXiv preprint arXiv:1405.0312, 2014.
  • Marcus et al. (1993) Marcus, Mitchell P, Marcinkiewicz, Mary Ann, and Santorini, Beatrice. Building a large annotated corpus of english: The penn treebank. Computational linguistics, 19(2):313–330, 1993.
  • Mikolov (2012) Mikolov, Tomáš. Statistical language models based on neural networks. PhD thesis, Ph. D. thesis, Brno University of Technology, 2012.
  • Mikolov & Zweig (2012) Mikolov, Tomas and Zweig, Geoffrey. Context dependent recurrent neural network language model. In SLT, pp. 234–239, 2012.
  • Mikolov et al. (2010) Mikolov, Tomas, Karafiát, Martin, Burget, Lukas, Cernockỳ, Jan, and Khudanpur, Sanjeev. Recurrent neural network based language model. In INTERSPEECH, pp. 1045–1048, 2010.
  • Mikolov et al. (2011) Mikolov, Tomas, Deoras, Anoop, Povey, Daniel, Burget, Lukas, and Cernocky, Jan. Strategies for training large scale neural network language models. In Automatic Speech Recognition and Understanding (ASRU), 2011 IEEE Workshop on, pp. 196–201. IEEE, 2011.
  • Mikolov et al. (2013) Mikolov, Tomas, Le, Quoc V, and Sutskever, Ilya. Exploiting similarities among languages for machine translation. arXiv preprint arXiv:1309.4168, 2013.
  • Pachitariu & Sahani (2013) Pachitariu, Marius and Sahani, Maneesh. Regularization and nonlinearities for neural language models: when are they needed? arXiv preprint arXiv:1301.5650, 2013.
  • Pascanu et al. (2013) Pascanu, Razvan, Gulcehre, Caglar, Cho, Kyunghyun, and Bengio, Yoshua. How to construct deep recurrent neural networks. arXiv preprint arXiv:1312.6026, 2013.
  • Pham et al. (2013) Pham, Vu, Kermorvant, Christopher, and Louradour, Jérôme. Dropout improves recurrent neural networks for handwriting recognition. arXiv preprint arXiv:1312.4569, 2013.
  • Robinson et al. (1996) Robinson, Tony, Hochberg, Mike, and Renals, Steve. The use of recurrent neural networks in continuous speech recognition. In Automatic speech and speaker recognition, pp. 233–258. Springer, 1996.
  • Sak et al. (2014) Sak, H., Vinyals, O., Heigold, G., Senior, A., McDermott, E., Monga, R., and Mao, M. Sequence discriminative distributed training of long short-term memory recurrent neural networks. In Interspeech, 2014.
  • Schwenk (2014) Schwenk, Holger. University le mans, 2014.
    http://www-lium.univ-lemans.fr/~schwenk/cslm_joint/paper.
  • Schwenk et al. (2011) Schwenk, Holger, Lambert, Patrik, Barrault, Loïc, Servan, Christophe, Afli, Haithem, Abdul-Rauf, Sadaf, and Shah, Kashif. Lium’s smt machine translation systems for wmt 2011. In Proceedings of the Sixth Workshop on Statistical Machine Translation, pp. 464–469. Association for Computational Linguistics, 2011.
  • Srivastava (2013) Srivastava, Nitish. Improving neural networks with dropout. PhD thesis, University of Toronto, 2013.
  • Sundermeyer et al. (2012) Sundermeyer, Martin, Schlüter, Ralf, and Ney, Hermann. Lstm neural networks for language modeling. In INTERSPEECH, 2012.
  • Sutskever et al. (2014) Sutskever, Ilya, Vinyals, Oriol, and Le, Quoc VV. Sequence to sequence learning with neural networks. In Advances in Neural Information Processing Systems, pp. 3104–3112, 2014.
  • Szegedy et al. (2014) Szegedy, Christian, Liu, Wei, Jia, Yangqing, Sermanet, Pierre, Reed, Scott, Anguelov, Dragomir, Erhan, Dumitru, Vanhoucke, Vincent, and Rabinovich, Andrew. Going deeper with convolutions. arXiv preprint arXiv:1409.4842, 2014.
  • Vinyals et al. (2014) Vinyals, Oriol, Toshev, Alexander, Bengio, Samy, and Erhan, Dumitru. Show and tell: A neural image caption generator. arXiv preprint arXiv:1411.4555, 2014.
  • Wan et al. (2013) Wan, Li, Zeiler, Matthew, Zhang, Sixin, Cun, Yann L, and Fergus, Rob. Regularization of neural networks using dropconnect. In Proceedings of the 30th International Conference on Machine Learning (ICML-13), pp. 1058–1066, 2013.
  • Wang & Manning (2013) Wang, Sida and Manning, Christopher. Fast dropout training. In Proceedings of the 30th International Conference on Machine Learning (ICML-13), pp. 118–126, 2013.