第8章現代の畳み込みニューラルネットワーク
8.1.1. Representation Learning8.1.1 表現学習
Another way to cast the state of affairs is that the most important part of the pipeline was the representation. And up until 2012 the representation was calculated mostly mechanically. In fact, engineering a new set of feature functions, improving results, and writing up the method all featured prominently in papers. SIFT (Lowe, 2004), SURF (Bay et al., 2006), HOG (histograms of oriented gradient) (Dalal and Triggs, 2005), bags of visual words (Sivic and Zisserman, 2003), and similar feature extractors ruled the roost.
英語のヒント
事態を別の形で言えば、パイプラインの最も重要な部分は表現だった、ということになる。そして2012年までは、表現はほとんど機械的に計算されていた。実際、新しい特徴関数の組を作り込み、結果を改善し、その手法を書き上げることが、どれも論文で目立った位置を占めていた。SIFT(Lowe, 2004)、SURF(Bay et al., 2006)、HOG(勾配方向ヒストグラム)(Dalal and Triggs, 2005)、視覚的単語のバッグ(Sivic and Zisserman, 2003)、そしてそれに似た特徴抽出器が幅をきかせていた。
Another group of researchers, including Yann LeCun, Geoff Hinton, Yoshua Bengio, Andrew Ng, Shun-ichi Amari, and Juergen Schmidhuber, had different plans. They believed that features themselves ought to be learned. Moreover, they believed that to be reasonably complex, the features ought to be hierarchically composed with multiple jointly learned layers, each with learnable parameters. In the case of an image, the lowest layers might come to detect edges, colors, and textures, by analogy with how the visual system in animals processes its input. In particular, the automatic design of visual features such as those obtained by sparse coding (Olshausen and Field, 1996) remained an open challenge until the advent of modern CNNs. It was not until Dean et al. (2012), Le (2013) that the idea of generating features from image data automatically gained significant traction.
英語のヒント
Yann LeCun、Geoff Hinton、Yoshua Bengio、Andrew Ng、甘利俊一、Juergen Schmidhuberをはじめとする別の研究者のグループは、違う計画をもっていた。彼らは、特徴量そのものを学習すべきだと考えていた。さらに、ほどよく複雑であるためには、特徴量は、それぞれ学習できるパラメータをもち、一緒に学習される複数の層によって、階層的に組み立てられるべきだと考えていた。画像の場合、動物の視覚系が入力をどう処理するかにならって、最も下の層は縁や色や質感を検出するようになるかもしれない。特に、スパース符号化(Olshausen and Field, 1996)で得られるもののような視覚的な特徴量を自動で設計することは、現代のCNNが登場するまで未解決の難題のままだった。画像データから特徴量を自動で生成するという考えが大きな支持を得たのは、Dean et al. (2012)やLe (2013)になってからのことである。
The first modern CNN (Krizhevsky et al., 2012), named AlexNet after one of its inventors, Alex Krizhevsky, is largely an evolutionary improvement over LeNet. It achieved excellent performance in the 2012 ImageNet challenge.
英語のヒント
最初の現代的なCNN(Krizhevsky et al., 2012)は、考案者の一人Alex KrizhevskyにちなんでAlexNetと名づけられ、おおむねLeNetを進化的に改良したものである。これは2012年のImageNetの課題で優れた性能を達成した。
Image omitted because its reuse rights could not be verified.権利の確認ができないため画像を割愛。
Fig. 8.1.1図8.1.1
Interestingly, in the lowest layers of the network, the model learned feature extractors that resembled some traditional filters. Fig. 8.1.1 shows lower-level image descriptors. Higher layers in the network might build upon these representations to represent larger structures, like eyes, noses, blades of grass, and so on. Even higher layers might represent whole objects like people, airplanes, dogs, or frisbees. Ultimately, the final hidden state learns a compact representation of the image that summarizes its contents such that data belonging to different categories can be easily separated.
英語のヒント
興味深いことに、ネットワークの最も下の層では、モデルはいくつかの伝統的なフィルタに似た特徴抽出器を学習した。図8.1.1は、低い水準の画像の記述子を示している。ネットワークのもっと上の層は、これらの表現を土台にして、目、鼻、草の葉などのような、もっと大きな構造を表すかもしれない。さらに上の層は、人、飛行機、犬、フリスビーのような物体全体を表すかもしれない。最終的には、最後の隠れ状態が、画像の中身を要約した簡潔な表現を学習し、異なるカテゴリーに属するデータを簡単に分けられるようにする。
AlexNet (2012) and its precursor LeNet (1995) share many architectural elements. This begs the question: why did it take so long? A key difference was that, over the previous two decades, the amount of data and the computing power available had increased significantly. As such AlexNet was much larger: it was trained on much more data, and on much faster GPUs compared to the CPUs available in 1995.
英語のヒント
AlexNet(2012年)とその前身であるLeNet(1995年)は、構造上の多くの要素を共有している。そうなると、なぜこれほど時間がかかったのかという疑問が湧く。鍵となる違いは、それまでの20年間で、手に入るデータの量と計算能力が大幅に増えていたことだった。そのため、AlexNetはずっと大きかった。ずっと多くのデータで、そして1995年に手に入ったCPUと比べてずっと速いGPUで訓練されたのである。
8.1.1.1. Missing Ingredient: Data8.1.1.1 欠けていた材料:データ
Deep models with many layers require large amounts of data in order to enter the regime where they significantly outperform traditional methods based on convex optimizations (e.g., linear and kernel methods). However, given the limited storage capacity of computers, the relative expense of (imaging) sensors, and the comparatively tighter research budgets in the 1990s, most research relied on tiny datasets. Numerous papers relied on the UCI collection of datasets, many of which contained only hundreds or (a few) thousands of images captured in low resolution and often with an artificially clean background.
英語のヒント
多くの層をもつ深いモデルが、凸最適化にもとづく伝統的な手法(たとえば線形の手法やカーネル法)を大きく上回る領域に入るには、大量のデータが必要である。しかし、1990年代には、コンピュータの記憶容量が限られ、(撮像)センサーが比較的高価で、研究予算も比較的厳しかったので、ほとんどの研究はごく小さなデータセットに頼っていた。数多くの論文がUCIのデータセット集に頼っていたが、その多くは、低解像度で、しばしば人工的にきれいな背景で撮られた、数百枚か(数)千枚の画像しか含んでいなかった。
In 2009, the ImageNet dataset was released (Deng et al., 2009), challenging researchers to learn models from 1 million examples, 1000 each from 1000 distinct categories of objects. The categories themselves were based on the most popular noun nodes in WordNet (Miller, 1995). The ImageNet team used Google Image Search to prefilter large candidate sets for each category and employed the Amazon Mechanical Turk crowdsourcing pipeline to confirm for each image whether it belonged to the associated category. This scale was unprecedented, exceeding others by over an order of magnitude (e.g., CIFAR-100 has 60,000 images). Another aspect was that the images were at relatively high resolution of pixels, unlike the 80 million-sized TinyImages dataset (Torralba et al., 2008), consisting of pixel thumbnails. This allowed for the formation of higher-level features. The associated competition, dubbed the ImageNet Large Scale Visual Recognition Challenge (Russakovsky et al., 2015), pushed computer vision and machine learning research forward, challenging researchers to identify which models performed best at a greater scale than academics had previously considered. The largest vision datasets, such as LAION-5B (Schuhmann et al., 2022) contain billions of images with additional metadata.
英語のヒント
2009年にImageNetデータセットが公開され(Deng et al., 2009)、研究者たちに、物体の1000の異なるカテゴリーからそれぞれ1000枚ずつ、100万の事例からモデルを学習するという課題を突きつけた。カテゴリーそのものは、WordNet(Miller, 1995)で最もよく使われる名詞のノードにもとづいていた。ImageNetのチームは、Googleの画像検索を使って各カテゴリーの大きな候補の集合をあらかじめふるい分け、Amazon Mechanical Turkのクラウドソーシングの仕組みを使って、各画像が対応するカテゴリーに属するかどうかを確かめた。この規模は前例がなく、ほかのデータセットを1桁以上上回っていた(たとえば、CIFAR-100の画像は6万枚である)。もう一つの面は、画素の縮小画像からなる8000万枚規模のTinyImagesデータセット(Torralba et al., 2008)と違って、画像が画素という比較的高い解像度だったことである。これにより、より高い水準の特徴量を形作れるようになった。ImageNet Large Scale Visual Recognition Challenge(Russakovsky et al., 2015)と名づけられた付随のコンペティションは、学術研究者がそれまで考えていたより大きな規模で、どのモデルが最もよい性能を出すかを見きわめるよう研究者たちに挑み、コンピュータビジョンと機械学習の研究を前に進めた。LAION-5B(Schuhmann et al., 2022)のような最大の視覚データセットは、追加のメタデータを伴う何十億枚もの画像を含んでいる。
8.1.1.2. Missing Ingredient: Hardware8.1.1.2 欠けていた材料:ハードウェア
Deep learning models are voracious consumers of compute cycles. Training can take hundreds of epochs, and each iteration requires passing data through many layers of computationally expensive linear algebra operations. This is one of the main reasons why in the 1990s and early 2000s, simple algorithms based on the more-efficiently optimized convex objectives were preferred.
英語のヒント
深層学習のモデルは、計算サイクルの貪欲な消費者である。訓練には何百エポックもかかることがあり、各反復では、計算の費用が高い線形代数の演算の層を何層もデータに通す必要がある。これが、1990年代と2000年代初めに、もっと効率よく最適化できる凸の目的関数にもとづく単純なアルゴリズムが好まれた主な理由の一つである。
Graphical processing units (GPUs) proved to be a game changer in making deep learning feasible. These chips had earlier been developed for accelerating graphics processing to benefit computer games. In particular, they were optimized for high throughput matrix–vector products, which are needed for many computer graphics tasks. Fortunately, the math is strikingly similar to that required for calculating convolutional layers. Around that time, NVIDIA and ATI had begun optimizing GPUs for general computing operations (Fernando, 2004), going as far as to market them as general-purpose GPUs (GPGPUs).
英語のヒント
画像処理装置(GPU)は、深層学習を実現可能にするうえで、局面を一変させるものとなった。これらのチップは、もともとはコンピュータゲームのためにグラフィックス処理を加速するよう開発されていた。特に、多くのコンピュータグラフィックスの課題に必要な、の行列とベクトルの積を高いスループットで行えるよう最適化されていた。幸い、その数学は、畳み込み層を計算するのに必要なものと驚くほど似ている。そのころ、NVIDIAとATIは、一般的な計算の演算のためにGPUを最適化し始めており(Fernando, 2004)、汎用GPU(GPGPU)として売り出すまでになっていた。
To provide some intuition, consider the cores of a modern microprocessor (CPU). Each of the cores is fairly powerful running at a high clock frequency and sporting large caches (up to several megabytes of L3). Each core is well-suited to executing a wide range of instructions, with branch predictors, a deep pipeline, specialized execution units, speculative execution, and many other bells and whistles that enable it to run a large variety of programs with sophisticated control flow. This apparent strength, however, is also its Achilles heel: general-purpose cores are very expensive to build. They excel at general-purpose code with lots of control flow. This requires lots of chip area, not just for the actual ALU (arithmetic logical unit) where computation happens, but also for all the aforementioned bells and whistles, plus memory interfaces, caching logic between cores, high-speed interconnects, and so on. CPUs are comparatively bad at any single task when compared with dedicated hardware. Modern laptops have 4–8 cores, and even high-end servers rarely exceed 64 cores per socket, simply because it is not cost-effective.
英語のヒント
直観をつかむため、現代のマイクロプロセッサ(CPU)のコアを考えてみよう。各コアはかなり強力で、高いクロック周波数で動き、大きなキャッシュ(L3で最大数メガバイト)を備えている。各コアは、分岐予測器、深いパイプライン、特化した実行ユニット、投機的実行、そのほか数多くのおまけの機能を備えて、幅広い命令を実行するのに向いており、それらによって、凝った制御フローをもつ多種多様なプログラムを走らせられる。しかし、この見かけの強みは、アキレス腱でもある。汎用のコアは作るのにとても費用がかかるのである。汎用のコアは、制御フローの多い汎用のコードを得意とする。これには、計算が実際に行われるALU(算術論理演算装置)のためだけでなく、前述のおまけの機能すべてや、メモリのインターフェース、コア間のキャッシュの論理回路、高速の相互接続などのために、チップの面積がたくさん必要になる。専用のハードウェアと比べると、CPUはどんな単一の課題も比較的苦手である。現代のノートパソコンには4〜8個のコアがあり、高級なサーバーでさえソケットあたり64コアを超えることはめったにない。単に費用対効果が合わないからである。
By comparison, GPUs can consist of thousands of small processing elements (NIVIDA’s latest Ampere chips have up to 6912 CUDA cores), often grouped into larger groups (NVIDIA calls them warps). The details differ somewhat between NVIDIA, AMD, ARM and other chip vendors. While each core is relatively weak, running at about 1GHz clock frequency, it is the total number of such cores that makes GPUs orders of magnitude faster than CPUs. For instance, NVIDIA’s recent Ampere A100 GPU offers over 300 TFLOPs per chip for specialized 16-bit precision (BFLOAT16) matrix-matrix multiplications, and up to 20 TFLOPs for more general-purpose floating point operations (FP32). At the same time, floating point performance of CPUs rarely exceeds 1 TFLOPs. For instance, Amazon’s Graviton 3 reaches 2 TFLOPs peak performance for 16-bit precision operations, a number similar to the GPU performance of Apple’s M1 processor.
英語のヒント
これに対して、GPUは数千個の小さな処理要素からなることがあり(NVIDIAの最新のAmpereチップには最大6912個のCUDAコアがある)、それらはしばしばもっと大きなグループにまとめられる(NVIDIAはそれをワープと呼ぶ)。細部は、NVIDIA、AMD、ARMやほかのチップメーカーのあいだで多少異なる。各コアは約1GHzのクロック周波数で動く比較的弱いものだが、GPUをCPUより何桁も速くしているのは、そうしたコアの総数である。たとえば、NVIDIAの最近のAmpere A100 GPUは、特化した16ビット精度(BFLOAT16)の行列どうしの掛け算でチップあたり300 TFLOPsを超え、もっと汎用の浮動小数点演算(FP32)でも最大20 TFLOPsを出す。一方、CPUの浮動小数点の性能が1 TFLOPsを超えることはめったにない。たとえば、AmazonのGraviton 3は16ビット精度の演算で最大2 TFLOPsに達するが、これはAppleのM1プロセッサのGPU性能と同じくらいの数である。
There are many reasons why GPUs are much faster than CPUs in terms of FLOPs. First, power consumption tends to grow quadratically with clock frequency. Hence, for the power budget of a CPU core that runs four times faster (a typical number), you can use 16 GPU cores at the speed, which yields times the performance. Second, GPU cores are much simpler (in fact, for a long time they were not even able to execute general-purpose code), which makes them more energy efficient. For instance, (i) they tend not to support speculative evaluation, (ii) it typically is not possible to program each processing element individually, and (iii) the caches per core tend to be much smaller. Last, many operations in deep learning require high memory bandwidth. Again, GPUs shine here with buses that are at least 10 times as wide as many CPUs.
英語のヒント
FLOPsの点でGPUがCPUよりずっと速い理由はたくさんある。第一に、消費電力はクロック周波数の2乗で増える傾向がある。そのため、4倍速く動くCPUのコア(典型的な数)の電力の予算で、の速さのGPUのコアを16個使え、倍の性能が得られる。第二に、GPUのコアはずっと単純で(実際、長いあいだ汎用のコードを実行することさえできなかった)、そのぶんエネルギーの効率がよい。たとえば、(i)投機的な評価をサポートしない傾向があり、(ii)ふつうは各処理要素を個別にプログラムできず、(iii)コアあたりのキャッシュはずっと小さい傾向がある。最後に、深層学習の多くの演算は高いメモリ帯域幅を必要とする。ここでもGPUは、多くのCPUの少なくとも10倍の幅のバスで輝く。
Back to 2012. A major breakthrough came when Alex Krizhevsky and Ilya Sutskever implemented a deep CNN that could run on GPUs. They realized that the computational bottlenecks in CNNs, convolutions and matrix multiplications, are all operations that could be parallelized in hardware. Using two NVIDIA GTX 580s with 3GB of memory, either of which was capable of 1.5 TFLOPs (still a challenge for most CPUs a decade later), they implemented fast convolutions. The cuda-convnet code was good enough that for several years it was the industry standard and powered the first couple of years of the deep learning boom.
英語のヒント
2012年に話を戻そう。大きな突破口が開かれたのは、Alex KrizhevskyとIlya Sutskeverが、GPU上で動く深いCNNを実装したときだった。彼らは、CNNの計算上のボトルネックである畳み込みと行列の掛け算が、どれもハードウェアで並列化できる演算であることに気づいた。どちらも1.5 TFLOPsを出せる(10年後でもほとんどのCPUにとって難しい値である)、メモリ3GBのNVIDIA GTX 580を2枚使って、彼らは高速な畳み込みを実装した。cuda-convnetのコードは十分に優れていて、何年ものあいだ業界標準であり続け、深層学習ブームの最初の数年を支えた。