プリンキピア

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

8.4.1. Inception Blocks8.4.1 Inceptionブロック

The basic convolutional block in GoogLeNet is called an Inception block, stemming from the meme “we need to go deeper” from the movie Inception.
英語のヒント
GoogLeNetの基本的な畳み込みブロックはInceptionブロックと呼ばれる。これは、映画『インセプション』の「もっと深く潜る必要がある」というミームに由来する。
Fig. 8.4.1図8.4.1
Structure of the Inception block.
英語のヒント
Inceptionブロックの構造。
As depicted in Fig. 8.4.1, the inception block consists of four parallel branches. The first three branches use convolutional layers with window sizes of 1×1, 3×3, and 5×5 to extract information from different spatial sizes. The middle two branches also add a 1×1 convolution of the input to reduce the number of channels, reducing the model’s complexity. The fourth branch uses a 3×3 max-pooling layer, followed by a 1×1 convolutional layer to change the number of channels. The four branches all use appropriate padding to give the input and output the same height and width. Finally, the outputs along each branch are concatenated along the channel dimension and comprise the block’s output. The commonly-tuned hyperparameters of the Inception block are the number of output channels per layer, i.e., how to allocate capacity among convolutions of different size.
英語のヒント
図8.4.1に描いたように、Inceptionブロックは四つの並列の枝からなる。最初の三つの枝は、窓の大きさが1×1、3×3、5×5の畳み込み層を使い、異なる空間的な大きさから情報を抽出する。真ん中の二つの枝は、チャネルの数を減らすために入力に1×1の畳み込みも加え、モデルの複雑さを下げる。4番目の枝は、3×3の最大プーリング層を使い、その後に1×1の畳み込み層を続けてチャネルの数を変える。四つの枝はどれも、入力と出力の高さと幅が同じになるよう、適切なパディングを使う。最後に、各枝の出力がチャネルの次元に沿って連結され、ブロックの出力となる。Inceptionブロックでよく調整されるハイパーパラメータは、層ごとの出力チャネルの数、つまり、異なる大きさの畳み込みのあいだに容量をどう割り振るかである。
class Inception(nn.Module):
    # c1--c4 are the number of output channels for each branch
    def __init__(self, c1, c2, c3, c4, **kwargs):
        super(Inception, self).__init__(**kwargs)
        # Branch 1
        self.b1_1 = nn.LazyConv2d(c1, kernel_size=1)
        # Branch 2
        self.b2_1 = nn.LazyConv2d(c2[0], kernel_size=1)
        self.b2_2 = nn.LazyConv2d(c2[1], kernel_size=3, padding=1)
        # Branch 3
        self.b3_1 = nn.LazyConv2d(c3[0], kernel_size=1)
        self.b3_2 = nn.LazyConv2d(c3[1], kernel_size=5, padding=2)
        # Branch 4
        self.b4_1 = nn.MaxPool2d(kernel_size=3, stride=1, padding=1)
        self.b4_2 = nn.LazyConv2d(c4, kernel_size=1)

    def forward(self, x):
        b1 = F.relu(self.b1_1(x))
        b2 = F.relu(self.b2_2(F.relu(self.b2_1(x))))
        b3 = F.relu(self.b3_2(F.relu(self.b3_1(x))))
        b4 = F.relu(self.b4_2(self.b4_1(x)))
        return torch.cat((b1, b2, b3, b4), dim=1)
To gain some intuition for why this network works so well, consider the combination of the filters. They explore the image in a variety of filter sizes. This means that details at different extents can be recognized efficiently by filters of different sizes. At the same time, we can allocate different amounts of parameters for different filters.
英語のヒント
このネットワークがなぜこれほどうまく働くのかの直観をつかむため、フィルタの組み合わせを考えてみよう。フィルタは、さまざまな大きさで画像を探る。つまり、異なる広がりの細部を、異なる大きさのフィルタで効率よく認識できる。同時に、異なるフィルタに異なる量のパラメータを割り振れる。