プリンキピア

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

8.7.3. Transition Layers8.7.3 遷移層

Since each dense block will increase the number of channels, adding too many of them will lead to an excessively complex model. A transition layer is used to control the complexity of the model. It reduces the number of channels by using a 1×1 convolution. Moreover, it halves the height and width via average pooling with a stride of 2.
英語のヒント
各密なブロックはチャネルの数を増やすので、密なブロックを加えすぎると、モデルが複雑になりすぎる。遷移層は、モデルの複雑さを制御するために使われる。遷移層は、1×1の畳み込みを使ってチャネルの数を減らす。さらに、ストライド2の平均プーリングによって高さと幅を半分にする。
def transition_block(num_channels):
    return nn.Sequential(
        nn.LazyBatchNorm2d(), nn.ReLU(),
        nn.LazyConv2d(num_channels, kernel_size=1),
        nn.AvgPool2d(kernel_size=2, stride=2))
Apply a transition layer with 10 channels to the output of the dense block in the previous example. This reduces the number of output channels to 10, and halves the height and width.
英語のヒント
前の例の密なブロックの出力に、10チャネルの遷移層を当てはめよう。これにより出力チャネルの数は10に減り、高さと幅は半分になる。
blk = transition_block(10)
blk(Y).shape
torch.Size([4, 10, 4, 4])