プリンキピア

第10章現代のリカレントニューラルネットワーク

10.1. Long Short-Term Memory (LSTM)10.1 長短期記憶(LSTM)

Shortly after the first Elman-style RNNs were trained using backpropagation (Elman, 1990), the problems of learning long-term dependencies (owing to vanishing and exploding gradients) became salient, with Bengio and Hochreiter discussing the problem (Bengio et al., 1994, Hochreiter et al., 2001). Hochreiter had articulated this problem as early as 1991 in his Master’s thesis, although the results were not widely known because the thesis was written in German. While gradient clipping helps with exploding gradients, handling vanishing gradients appears to require a more elaborate solution. One of the first and most successful techniques for addressing vanishing gradients came in the form of the long short-term memory (LSTM) model due to Hochreiter and Schmidhuber (1997). LSTMs resemble standard recurrent neural networks but here each ordinary recurrent node is replaced by a memory cell. Each memory cell contains an internal state, i.e., a node with a self-connected recurrent edge of fixed weight 1, ensuring that the gradient can pass across many time steps without vanishing or exploding.
英語のヒント
最初のエルマン型のRNNが逆伝播で訓練されて間もなく(Elman, 1990)、(勾配の消失と爆発のせいで)長期的な依存関係を学習することの問題が目立つようになり、BengioとHochreiterがこの問題を論じた(Bengio et al., 1994、Hochreiter et al., 2001)。Hochreiterは早くも1991年に修士論文でこの問題を明確に述べていたが、論文がドイツ語で書かれていたので、その結果は広くは知られていなかった。勾配クリッピングは勾配の爆発には役立つが、勾配の消失を扱うには、もっと手の込んだ解決策が必要なようである。勾配の消失に対処する最初の、そして最も成功した手法の一つは、Hochreiter and Schmidhuber (1997)による長短期記憶(LSTM)モデルという形で現れた。LSTMは標準的なリカレントニューラルネットワークに似ているが、ここでは通常の再帰的なノードがそれぞれメモリセルに置き換えられている。各メモリセルは内部状態、つまり重みが1に固定された自己接続の再帰的な辺をもつノードを含み、勾配が消失も爆発もせずに多くの時間ステップをまたいで通れるようにしている。
The term “long short-term memory” comes from the following intuition. Simple recurrent neural networks have long-term memory in the form of weights. The weights change slowly during training, encoding general knowledge about the data. They also have short-term memory in the form of ephemeral activations, which pass from each node to successive nodes. The LSTM model introduces an intermediate type of storage via the memory cell. A memory cell is a composite unit, built from simpler nodes in a specific connectivity pattern, with the novel inclusion of multiplicative nodes.
英語のヒント
「長短期記憶」という言葉は、次の直観から来ている。単純なリカレントニューラルネットワークは、重みという形で長期記憶をもつ。重みは訓練中にゆっくり変わり、データについての一般的な知識を符号化する。また、各ノードから続くノードへ渡される、つかの間の活性値という形で短期記憶ももつ。LSTMモデルは、メモリセルによって中間的な種類の記憶を導入する。メモリセルは、特定の接続パターンをなす単純なノードから組み立てられた複合的な単位であり、乗算のノードを含む点が新しい。
import torch
from torch import nn
from d2l import torch as d2l