第7章畳み込みニューラルネットワーク
7.5.3. Multiple Channels7.5.3 複数のチャネル
When processing multi-channel input data, the pooling layer pools each input channel separately, rather than summing the inputs up over channels as in a convolutional layer. This means that the number of output channels for the pooling layer is the same as the number of input channels. Below, we will concatenate tensors
X and X + 1 on the channel dimension to construct an input with two channels.英語のヒント
複数チャネルの入力データを処理するとき、プーリング層は、畳み込み層のようにチャネルにわたって入力の和をとるのではなく、各入力チャネルを別々にプーリングする。つまり、プーリング層の出力チャネルの数は、入力チャネルの数と同じである。下では、テンソル
XとX + 1をチャネルの次元で連結して、二つのチャネルをもつ入力を作る。X = torch.cat((X, X + 1), 1)
Xtensor([[[[ 0., 1., 2., 3.],
[ 4., 5., 6., 7.],
[ 8., 9., 10., 11.],
[12., 13., 14., 15.]],
[[ 1., 2., 3., 4.],
[ 5., 6., 7., 8.],
[ 9., 10., 11., 12.],
[13., 14., 15., 16.]]]])As we can see, the number of output channels is still two after pooling.
英語のヒント
見てのとおり、プーリングの後も出力チャネルの数は2のままである。
pool2d = nn.MaxPool2d(3, padding=1, stride=2)
pool2d(X)tensor([[[[ 5., 7.],
[13., 15.]],
[[ 6., 8.],
[14., 16.]]]])