https://zh.d2l.ai/chapter_convolutional-neural-networks/pooling.html
import torch
from torch import nn
conv = nn.Conv2d(1, 1, kernel_size=(2, 2), bias=False)
pool = nn.AvgPool2d((2, 2), stride=1)
X = torch.rand((6, 6)).reshape((1, 1, 6, 6))
h_k, w_k = conv.kernel_size
conv.weight.data[:] = (1 / (h_k * w_k))
print(conv(X) == pool(X))
tensor([[[[True, True, True, True, True],
[True, True, True, True, True],
[True, True, True, True, True],
[True, True, True, True, True],
[True, True, True, True, True]]]])
平均pooling实际上就是conv kernel的权重为1/(h_p * w_p)
本节将介绍汇聚层,它具有双重目的:降低卷积层对位置的敏感性,同时降低对空间降采样表示的敏感性。
这里应该翻译错了,原文是:
This section introduces pooling layers, which serve the dual purposes of mitigating the sensitivity of convolutional layers to location and of spatially downsampling representations.
应该是 serve the dual purposes of A and of B
即
本节将介绍汇聚层,它具有双重目的:降低卷积层对位置的敏感性,以及在空间维度上对表示进行降采样。