调用预训练模型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. 参考:https://github.com/pytorch/vision/issues/696
原文地址:https://www.cnblogs.com/dyclown/p/12587390.html
时间: 2024-10-07 07:28:08