迁移学习调用预训练模型出现Given input size: (512x3x3). Calculated output size: (512x-3x-3)错误
调用预训练模型 ResNet18 时报错:RuntimeError: Given input size: (512x3x3). Calculated output size: (512x-3x-3).
Output size is too small at /opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THCUNN/generic/SpatialAveragePooling.cu:63
其解决方法是将倒数第二层的 self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) 替换为 self.avgpool = nn.AdaptiveAvgPool2d(1) 即可。具体原因可能是一个bug.