本地加载Wide_ResNet_50_2的预训练模型的方法
Wide_ResNet_50_2是指50层深,通道数变为ResNet50的两倍的WRN
WRN官方说明文档:
https://pytorch.org/hub/pytorch_vision_wide_resnet/
使用官方说明文档加载WRN需要下载。在下载时遇到了
的错误。
常用ResNet预训练模型下载地址:
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-f37072fd.pth',
'resnet34': 'https://download.pytorch.org/models/resnet34-b627a593.pth',
'resnet50': 'https://download.pytorch.org/models/resnet50-0676ba61.pth',
'resnet101': 'https://download.pytorch.org/models/resnet101-63fe2227.pth',
'resnet152': 'https://download.pytorch.org/models/resnet152-394f9c45.pth',
'resnext50_32x4d': 'https://download.pytorch.org/models/resnext50_32x4d-7cdf4587.pth',
'resnext101_32x8d': 'https://download.pytorch.org/models/resnext101_32x8d-8ba56ff5.pth',
'wide_resnet50_2': 'https://download.pytorch.org/models/wide_resnet50_2-95faca4d.pth',
'wide_resnet101_2': 'https://download.pytorch.org/models/wide_resnet101_2-32ee1156.pth',
}
下载完成后加载模型:
self.model = models.wide_resnet50_2
(pretrained=False)
self.model.load_state_dict(torch.load('./model/resnet50-19c8e357.pth'))