プリンキピア

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

8.3.1. NiN Blocks8.3.1 NiNブロック

Recall Section 7.4.3. In it we said that the inputs and outputs of convolutional layers consist of four-dimensional tensors with axes corresponding to the example, channel, height, and width. Also recall that the inputs and outputs of fully connected layers are typically two-dimensional tensors corresponding to the example and feature. The idea behind NiN is to apply a fully connected layer at each pixel location (for each height and width). The resulting 1×1 convolution can be thought of as a fully connected layer acting independently on each pixel location.
英語のヒント
7.4.3節を思い出そう。そこでは、畳み込み層の入力と出力は、事例、チャネル、高さ、幅に対応する軸をもつ4次元のテンソルからなると述べた。また、全結合層の入力と出力は、ふつう事例と特徴量に対応する2次元のテンソルであることも思い出そう。NiNの背後にある考えは、各画素の位置で(高さと幅ごとに)全結合層を当てはめることである。こうしてできる1×1の畳み込みは、各画素の位置で独立に働く全結合層とみなせる。
Fig. 8.3.1 illustrates the main structural differences between VGG and NiN, and their blocks. Note both the difference in the NiN blocks (the initial convolution is followed by 1×1 convolutions, whereas VGG retains 3×3 convolutions) and at the end where we no longer require a giant fully connected layer.
英語のヒント
図8.3.1は、VGGとNiNの構造上の主な違いと、それぞれのブロックの違いを示している。NiNブロックの違い(最初の畳み込みの後に1×1の畳み込みが続くのに対し、VGGは3×3の畳み込みを保っている)と、最後の部分で巨大な全結合層がもはや必要ないことの両方に注意してほしい。
Fig. 8.3.1図8.3.1
Comparing the architectures of VGG and NiN, and of their blocks.
英語のヒント
VGGとNiNの構造、およびそれぞれのブロックの比較。
def nin_block(out_channels, kernel_size, strides, padding):
    return nn.Sequential(
        nn.LazyConv2d(out_channels, kernel_size, strides, padding), nn.ReLU(),
        nn.LazyConv2d(out_channels, kernel_size=1), nn.ReLU(),
        nn.LazyConv2d(out_channels, kernel_size=1), nn.ReLU())