プリンキピア

第8章現代の畳み込みニューラルネットワーク

8.3. Network in Network (NiN)8.3 ネットワーク・イン・ネットワーク(NiN)

LeNet, AlexNet, and VGG all share a common design pattern: extract features exploiting spatial structure via a sequence of convolutions and pooling layers and post-process the representations via fully connected layers. The improvements upon LeNet by AlexNet and VGG mainly lie in how these later networks widen and deepen these two modules.
英語のヒント
LeNet、AlexNet、VGGはどれも、共通の設計パターンをもっている。畳み込みとプーリング層を並べて空間構造を活かした特徴量を抽出し、その表現を全結合層で後処理する、というものである。AlexNetとVGGによるLeNetの改良は、主に、これら後のネットワークがこの二つのモジュールをどう広く深くしたかにある。
This design poses two major challenges. First, the fully connected layers at the end of the architecture consume tremendous numbers of parameters. For instance, even a simple model such as VGG-11 requires a monstrous matrix, occupying almost 400MB of RAM in single precision (FP32). This is a significant impediment to computation, in particular on mobile and embedded devices. After all, even high-end mobile phones sport no more than 8GB of RAM. At the time VGG was invented, this was an order of magnitude less (the iPhone 4S had 512MB). As such, it would have been difficult to justify spending the majority of memory on an image classifier.
英語のヒント
この設計には、二つの大きな難題がある。第一に、構造の最後にある全結合層は、とてつもない数のパラメータを消費する。たとえば、VGG-11のような単純なモデルでさえ、単精度(FP32)で400MB近いRAMを占める巨大な行列を必要とする。これは、特に携帯機器や組み込み機器での計算にとって大きな妨げである。結局のところ、高級な携帯電話でさえ、RAMは8GBしか積んでいない。VGGが考案された当時は、これより1桁少なかった(iPhone 4Sは512MBだった)。そのため、メモリの大半を画像分類器に費やすことを正当化するのは難しかっただろう。
Second, it is equally impossible to add fully connected layers earlier in the network to increase the degree of nonlinearity: doing so would destroy the spatial structure and require potentially even more memory.
英語のヒント
第二に、非線形性の度合いを上げるために、ネットワークのもっと前の位置に全結合層を加えることも、同じく不可能である。そうすると空間構造が壊れ、ことによるとさらに多くのメモリが必要になるからである。
The network in network (NiN) blocks (Lin et al., 2013) offer an alternative, capable of solving both problems in one simple strategy. They were proposed based on a very simple insight: (i) use 1×1 convolutions to add local nonlinearities across the channel activations and (ii) use global average pooling to integrate across all locations in the last representation layer. Note that global average pooling would not be effective, were it not for the added nonlinearities. Let’s dive into this in detail.
英語のヒント
ネットワーク・イン・ネットワーク(NiN)のブロック(Lin et al., 2013)は、一つの単純な戦略で両方の問題を解決できる代替案を示す。これは、とても単純な洞察にもとづいて提案された。(i)1×1の畳み込みを使って、チャネルの活性値にまたがる局所的な非線形性を加え、(ii)大域平均プーリングを使って、最後の表現層のすべての位置にわたって統合する、というものである。加えた非線形性がなければ、大域平均プーリングは効果的でないことに注意してほしい。これを詳しく見ていこう。
import torch
from torch import nn
from d2l import torch as d2l