第9章リカレントニューラルネットワーク
9. Recurrent Neural Networks9 リカレントニューラルネットワーク
Up until now, we have focused primarily on fixed-length data. When introducing linear and logistic regression in Section 3 and Section 4 and multilayer perceptrons in Section 5, we were happy to assume that each feature vector consisted of a fixed number of components , where each numerical feature corresponded to a particular attribute. These datasets are sometimes called tabular, because they can be arranged in tables, where each example gets its own row, and each attribute gets its own column. Crucially, with tabular data, we seldom assume any particular structure over the columns.
英語のヒント
Subsequently, in Section 7, we moved on to image data, where inputs consist of the raw pixel values at each coordinate in an image. Image data hardly fitted the bill of a protypical tabular dataset. There, we needed to call upon convolutional neural networks (CNNs) to handle the hierarchical structure and invariances. However, our data were still of fixed length. Every Fashion-MNIST image is represented as a grid of pixel values. Moreover, our goal was to develop a model that looked at just one image and then outputted a single prediction. But what should we do when faced with a sequence of images, as in a video, or when tasked with producing a sequentially structured prediction, as in the case of image captioning?
英語のヒント
続いて第7章では、画像データに移った。そこでは、入力は画像の各座標における生の画素値からなる。画像データは、典型的な表形式のデータセットの条件にはほとんど合わなかった。そこでは、階層的な構造と不変性を扱うために、畳み込みニューラルネットワーク(CNN)を持ち出す必要があった。しかし、データはまだ固定長だった。Fashion-MNISTの画像はどれも、画素値のの格子として表される。さらに、目標は、一枚の画像だけを見て一つの予測を出力するモデルを作ることだった。しかし、動画のように一連の画像を前にしたときや、画像のキャプション生成のように、系列として構造化された予測を生み出す課題を与えられたときには、どうすればよいだろうか。
A great many learning tasks require dealing with sequential data. Image captioning, speech synthesis, and music generation all require that models produce outputs consisting of sequences. In other domains, such as time series prediction, video analysis, and musical information retrieval, a model must learn from inputs that are sequences. These demands often arise simultaneously: tasks such as translating passages of text from one natural language to another, engaging in dialogue, or controlling a robot, demand that models both ingest and output sequentially structured data.
英語のヒント
とても多くの学習の課題で、系列データを扱う必要がある。画像のキャプション生成、音声合成、音楽の生成はどれも、モデルが系列からなる出力を生み出すことを求める。時系列の予測、動画の解析、音楽の情報検索といったほかの領域では、モデルは系列である入力から学習しなければならない。こうした要求は、しばしば同時に生じる。ある自然言語から別の自然言語へ文章を翻訳する、対話をする、ロボットを制御するといった課題では、モデルが系列として構造化されたデータを取り込みも出力もすることが求められる。
Recurrent neural networks (RNNs) are deep learning models that capture the dynamics of sequences via recurrent connections, which can be thought of as cycles in the network of nodes. This might seem counterintuitive at first. After all, it is the feedforward nature of neural networks that makes the order of computation unambiguous. However, recurrent edges are defined in a precise way that ensures that no such ambiguity can arise. Recurrent neural networks are unrolled across time steps (or sequence steps), with the same underlying parameters applied at each step. While the standard connections are applied synchronously to propagate each layer’s activations to the subsequent layer at the same time step, the recurrent connections are dynamic, passing information across adjacent time steps. As the unfolded view in Fig. 9.1 reveals, RNNs can be thought of as feedforward neural networks where each layer’s parameters (both conventional and recurrent) are shared across time steps.
英語のヒント
リカレントニューラルネットワーク(RNN)は、再帰的な接続によって系列の動態をとらえる深層学習のモデルである。再帰的な接続は、ノードのネットワークの中の閉路とみなせる。これは初めは直観に反するように見えるかもしれない。結局のところ、計算の順序を曖昧さのないものにしているのは、ニューラルネットワークの順伝播型という性質である。しかし、再帰的な辺は、そうした曖昧さが生じえないことを保証する厳密なやり方で定義される。リカレントニューラルネットワークは時間ステップ(あるいは系列のステップ)にわたって展開され、各ステップで同じパラメータが当てはめられる。標準的な接続は、各層の活性値を同じ時間ステップの次の層へ伝えるために同期して当てはめられるのに対し、再帰的な接続は動的で、隣り合う時間ステップのあいだで情報を渡す。図9.1の展開した図が示すように、RNNは、各層のパラメータ(通常のものと再帰的なものの両方)が時間ステップのあいだで共有される順伝播型ニューラルネットワークとみなせる。
Fig. 9.1図9.1
On the left recurrent connections are depicted via cyclic edges. On the right, we unfold the RNN over time steps. Here, recurrent edges span adjacent time steps, while conventional connections are computed synchronously.
英語のヒント
左では、再帰的な接続を閉路の辺で描いている。右では、RNNを時間ステップにわたって展開している。ここでは、再帰的な辺は隣り合う時間ステップにまたがり、通常の接続は同期して計算される。
Like neural networks more broadly, RNNs have a long discipline-spanning history, originating as models of the brain popularized by cognitive scientists and subsequently adopted as practical modeling tools employed by the machine learning community. As we do for deep learning more broadly, in this book we adopt the machine learning perspective, focusing on RNNs as practical tools that rose to popularity in the 2010s owing to breakthrough results on such diverse tasks as handwriting recognition (Graves et al., 2008), machine translation (Sutskever et al., 2014), and recognizing medical diagnoses (Lipton et al., 2016). We point the reader interested in more background material to a publicly available comprehensive review (Lipton et al., 2015). We also note that sequentiality is not unique to RNNs. For example, the CNNs that we already introduced can be adapted to handle data of varying length, e.g., images of varying resolution. Moreover, RNNs have recently ceded considerable market share to Transformer models, which will be covered in Section 11. However, RNNs rose to prominence as the default models for handling complex sequential structure in deep learning, and remain staple models for sequential modeling to this day. The stories of RNNs and of sequence modeling are inextricably linked, and this is as much a chapter about the ABCs of sequence modeling problems as it is a chapter about RNNs.
英語のヒント
ニューラルネットワーク全般と同じように、RNNにも分野をまたぐ長い歴史がある。認知科学者が広めた脳のモデルとして始まり、その後、機械学習のコミュニティが使う実用的なモデリングの道具として採り入れられた。深層学習全般についてそうしているように、この本では機械学習の観点をとり、RNNを、手書き文字認識(Graves et al., 2008)、機械翻訳(Sutskever et al., 2014)、医療の診断の認識(Lipton et al., 2016)といった多様な課題での画期的な結果によって2010年代に人気を得た実用的な道具として扱う。もっと背景の資料に興味のある読者には、公開されている包括的な概説(Lipton et al., 2015)を勧める。また、系列性はRNNだけのものではないことにも注意しておく。たとえば、すでに紹介したCNNは、長さの異なるデータ、たとえば解像度の異なる画像を扱えるよう改造できる。さらに、RNNは最近、第11章で扱うTransformerのモデルにかなりの市場シェアを譲った。しかし、RNNは深層学習で複雑な系列構造を扱うための既定のモデルとして台頭し、今日でも系列のモデリングの定番であり続けている。RNNの話と系列のモデリングの話は切っても切り離せず、この章はRNNについての章であるのと同じくらい、系列のモデリングの問題の基本についての章でもある。
One key insight paved the way for a revolution in sequence modeling. While the inputs and targets for many fundamental tasks in machine learning cannot easily be represented as fixed-length vectors, they can often nevertheless be represented as varying-length sequences of fixed-length vectors. For example, documents can be represented as sequences of words; medical records can often be represented as sequences of events (encounters, medications, procedures, lab tests, diagnoses); videos can be represented as varying-length sequences of still images.
英語のヒント
一つの鍵となる洞察が、系列のモデリングの革命への道を開いた。機械学習の多くの基本的な課題の入力と目標は、固定長のベクトルとして簡単には表せないが、それでもしばしば、固定長のベクトルの可変長の系列として表せる。たとえば、文書は単語の系列として表せる。医療記録はしばしば出来事(受診、投薬、処置、臨床検査、診断)の系列として表せる。動画は静止画像の可変長の系列として表せる。
While sequence models have popped up in numerous application areas, basic research in the area has been driven predominantly by advances on core tasks in natural language processing. Thus, throughout this chapter, we will focus our exposition and examples on text data. If you get the hang of these examples, then applying the models to other data modalities should be relatively straightforward. In the next few sections, we introduce basic notation for sequences and some evaluation measures for assessing the quality of sequentially structured model outputs. After that, we discuss basic concepts of a language model and use this discussion to motivate our first RNN models. Finally, we describe the method for calculating gradients when backpropagating through RNNs and explore some challenges that are often encountered when training such networks, motivating the modern RNN architectures that will follow in Section 10.
英語のヒント
系列モデルは数多くの応用分野に現れてきたが、この分野の基礎研究は、主に自然言語処理の中核的な課題での進歩によって推し進められてきた。そのため、この章を通じて、説明と例はテキストデータに絞る。これらの例のこつをつかめば、モデルをほかの種類のデータに当てはめるのは比較的簡単なはずである。以下のいくつかの節では、系列の基本的な表記と、系列として構造化されたモデルの出力の質を評価するための評価尺度をいくつか紹介する。その後、言語モデルの基本的な概念を論じ、その議論を使って最初のRNNのモデルへの動機づけとする。最後に、RNNを通じて逆伝播するときに勾配を計算する方法を説明し、そうしたネットワークを訓練するときによく出会う難題をいくつか探る。それが、第10章で続く現代のRNNの構造への動機となる。