pytorch 加载预训练模型

https://pytorch.org/docs/1.1.0/torchvision/models.html?highlight=models
在这里插入图片描述import torchvision.models as models
resnet18 = models.resnet18()
alexnet = models.alexnet()
vgg16 = models.vgg16()
squeezenet = models.squeezenet1_0()
densenet = models.densenet161()
inception = models.inception_v3()
googlenet = models.googlenet()
shufflenet = models.shufflenet_v2_x1_0()
mobilenet = models.mobilenet_v2()
resnext50_32x4d = models.resnext50_32x4d()

import torchvision.models as models
resnet18 = models.resnet18(pretrained=True)
alexnet = models.alexnet(pretrained=True)
squeezenet = models.squeezenet1_0(pretrained=True)
vgg16 = models.vgg16(pretrained=True)
densenet = models.densenet161(pretrained=True)
inception = models.inception_v3(pretrained=True)
googlenet = models.googlenet(pretrained=True)
shufflenet = models.shufflenet_v2_x1_0(pretrained=True)
mobilenet = models.mobilenet_v2(pretrained=True)
resnext50_32x4d = models.resnext50_32x4d(pretrained=True)

import torchvision.models as models
resnet18 = models.resnet18()
alexnet = models.alexnet()
vgg16 = models.vgg16()
squeezenet = models.squeezenet1_0()
densenet = models.densenet161()
inception = models.inception_v3()
googlenet = models.googlenet()
shufflenet = models.googlenet()
mobilenet = models.mobilenet_v2()
resnet50_32x4d = models.resnet50_32x4d()


resnet50 = models.resnet50(pretrained =True)
或者
resnet50 = models.resnet50()
#使用本地磁盘上的模型参数文件
state_dict = torch.load('resnet50.pth')
#把读入的模型参数加载到模型model中:
resnet50.load_state_dict(state_dict)

将下载好的模型放在~/.cache/torch/checkpoints文件夹中即可(windows为C:\用户名.cache\torch.checkpoints)

Resnet:

model_urls = {
‘resnet18’: ‘https://download.pytorch.org/models/resnet18-5c106cde.pth’,
‘resnet34’: ‘https://download.pytorch.org/models/resnet34-333f7ec4.pth’,
‘resnet50’: ‘https://download.pytorch.org/models/resnet50-19c8e357.pth’,
‘resnet101’: ‘https://download.pytorch.org/models/resnet101-5d3b4d8f.pth’,
‘resnet152’: ‘https://download.pytorch.org/models/resnet152-b121ed2d.pth’,
}

inception:

model_urls = {
# Inception v3 ported from TensorFlow
‘inception_v3_google’: ‘https://download.pytorch.org/models/inception_v3_google-1a9a5a14.pth’,
}

Densenet:

model_urls = {
‘densenet121’: ‘https://download.pytorch.org/models/densenet121-a639ec97.pth’,
‘densenet169’: ‘https://download.pytorch.org/models/densenet169-b2777c0a.pth’,
‘densenet201’: ‘https://download.pytorch.org/models/densenet201-c1103571.pth’,
‘densenet161’: ‘https://download.pytorch.org/models/densenet161-8d451a50.pth’,
}

Alexnet:

model_urls = {
‘alexnet’: ‘https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth’,
}

vggnet:

model_urls = {
‘vgg11’: ‘https://download.pytorch.org/models/vgg11-bbd30ac9.pth’,
‘vgg13’: ‘https://download.pytorch.org/models/vgg13-c768596a.pth’,
‘vgg16’: ‘https://download.pytorch.org/models/vgg16-397923af.pth’,
‘vgg19’: ‘https://download.pytorch.org/models/vgg19-dcbb9e9d.pth’,
‘vgg11_bn’: ‘https://download.pytorch.org/models/vgg11_bn-6002323d.pth’,
‘vgg13_bn’: ‘https://download.pytorch.org/models/vgg13_bn-abd245e5.pth’,
‘vgg16_bn’: ‘https://download.pytorch.org/models/vgg16_bn-6c64b313.pth’,
‘vgg19_bn’: ‘https://download.pytorch.org/models/vgg19_bn-c79401a0.pth’,
}
————————————————
版权声明:本文为CSDN博主「沃兹基.硕德」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sumaliqinghua/article/details/90903590

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值