This action will force synchronization from OpenDocCN/pytorch-doc-zh, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
torchvision.models
模块的 子模块中包含以下模型结构。
可以通过调用构造函数来构造具有随机权重的模型:
import torchvision.models as models
resnet18 = models.resnet18()
alexnet = models.alexnet()
squeezenet = models.squeezenet1_0()
densenet = models.densenet_161()
我们提供的 Pathway 变体和 alexnet 预训练的模型,利用 pytorch 的torch.utils.model_zoo
。这些可以通过构建pretrained=True
:
import torchvision.models as models
resnet18 = models.resnet18(pretrained=True)
alexnet = models.alexnet(pretrained=True)
所有预训练的模型的期望输入图像相同的归一化,即小批量形状通道的 RGB 图像(3 x H x W),其中 H 和 W 预计将至少 224。这些图像必须被加载到[ 0, 1 ]的范围内,然后使用平均= [ 0.485,0.456,0.406 ]和 STD=[ 0.229,0.224,0.225 ]进行归一化。您可以使用以下转换来正常化:
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225])
这种规范化的一个例子可以在这里找到 ImageNet 的例子 ImageNet 1-crop 错误率(224x224)
Network | Top-1 error | Top-5 error |
---|---|---|
ResNet-18 | 30.24 | 10.92 |
ResNet-34 | 26.70 | 8.58 |
ResNet-50 | 23.85 | 7.13 |
ResNet-101 | 22.63 | 6.44 |
ResNet-152 | 21.69 | 5.94 |
Inception v3 | 22.55 | 6.44 |
AlexNet | 43.45 | 20.91 |
VGG-11 | 30.98 | 11.37 |
VGG-13 | 30.07 | 10.75 |
VGG-16 | 28.41 | 9.62 |
VGG-19 | 27.62 | 9.12 |
SqueezeNet 1.0 | 41.90 | 19.58 |
SqueezeNet 1.1 | 41.81 | 19.38 |
Densenet-121 | 25.35 | 7.83 |
Densenet-169 | 24.00 | 7.00 |
Densenet-201 | 22.80 | 6.43 |
Densenet-161 | 22.35 | 6.20 |
torchvision.models.alexnet(pretrained=False, ** kwargs)
AlexNet 模型结构 paper 地址
pretrained (bool) – True, 返回在 ImageNet 上训练好的模型。
torchvision.models.resnet18(pretrained=False, ** kwargs)
构建一个 resnet18 模型 pretrained (bool) – True, 返回在 ImageNet 上训练好的模型。
torchvision.models.resnet34(pretrained=False, ** kwargs)
构建一个 ResNet-34 模型. Parameters: pretrained (bool) – True, 返回在 ImageNet 上训练好的模型。
torchvision.models.resnet50(pretrained=False, ** kwargs)
构建一个 ResNet-50 模型
pretrained (bool) – True, 返回在 ImageNet 上训练好的模型。
torchvision.models.resnet101(pretrained=False, ** kwargs)
构建一个 ResNet-101 模型.
pretrained (bool) – True, 返回在 ImageNet 上训练好的模型。
torchvision.models.resnet152(pretrained=False, ** kwargs)
构建一个 ResNet-152 模型.
pretrained (bool) – True, 返回在 ImageNet 上训练好的模型。
torchvision.models.vgg11(pretrained=False, ** kwargs)
VGG 11-layer model (configuration “A”) -
pretrained (bool) – True, 返回在 ImageNet 上训练好的模型。
torchvision.models.vgg11_bn(** kwargs)
VGG 11-layer model (configuration “A”) with batch normalization
torchvision.models.vgg13(pretrained=False, ** kwargs)
VGG 13-layer model (configuration “B”)
pretrained (bool) – True, 返回在 ImageNet 上训练好的模型。
torchvision.models.vgg13_bn(** kwargs)
VGG 13-layer model (configuration “B”) with batch normalization
torchvision.models.vgg16(pretrained=False, ** kwargs)
VGG 16-layer model (configuration “D”)
Parameters: pretrained (bool) – If True, returns a model pre-trained on ImageNet
torchvision.models.vgg16_bn(** kwargs)
VGG 16-layer model (configuration “D”) with batch normalization
torchvision.models.vgg19(pretrained=False, ** kwargs)
VGG 19-layer model (configuration “E”)
pretrained (bool) – True, 返回在 ImageNet 上训练好的模型。
torchvision.models.vgg19_bn(** kwargs)
VGG 19-layer model (configuration ‘E’) with batch normalization
用户名 | 头像 | 职能 | 签名 |
---|---|---|---|
Song | ![]() |
翻译 | 人生总要追求点什么 |
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。