# torchvision.models
# torchvision.models
`torchvision.models`模块的 子模块中包含以下模型结构。
- AlexNet
- VGG
- ResNet
- SqueezeNet
- DenseNet You can construct a model with random weights by calling its constructor:
你可以使用随机初始化的权重来创建这些模型。
```
import torchvision.models as models
resnet18 = models.resnet18()
alexnet = models.alexnet()
squeezenet = models.squeezenet1_0()
densenet = models.densenet_161()
```
We provide pre-trained models for the ResNet variants and AlexNet, using the PyTorch torch.utils.model\_zoo. These can constructed by passing pretrained=True: 对于`ResNet variants`和`AlexNet`,我们也提供了预训练(`pre-trained`)的模型。
```
import torchvision.models as models
#pretrained=True就可以使用预训练的模型
resnet18 = models.resnet18(pretrained=True)
alexnet = models.alexnet(pretrained=True)
```
ImageNet 1-crop error rates (224x224)
NetworkTop-1 errorTop-5 errorResNet-1830.2410.92ResNet-3426.708.58ResNet-5023.857.13ResNet-10122.636.44ResNet-15221.695.94Inception v322.556.44AlexNet43.4520.91VGG-1130.9811.37VGG-1330.0710.75VGG-1628.419.62VGG-1927.629.12SqueezeNet 1.041.9019.58SqueezeNet 1.141.8119.38Densenet-12125.357.83Densenet-16924.007.00Densenet-20122.806.43Densenet-16122.356.20## torchvision.models.alexnet(pretrained=False, \*\* kwargs)
`AlexNet` 模型结构 [paper地址](https://arxiv.org/abs/1404.5997)
- 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)
Constructs a ResNet-101 model.
- pretrained (bool) – `True`, 返回在ImageNet上训练好的模型。
## torchvision.models.resnet152(pretrained=False, \*\* kwargs)
Constructs a ResNet-152 model.
- 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
- PyTorch 中文文档
- 主页
- 自动求导机制
- CUDA语义
- 扩展PyTorch
- 多进程最佳实践
- 序列化语义
- torch
- torch.Tensor
- torch.Storage
- torch.nn
- torch.nn.functional
- torch.autograd
- torch.optim
- torch.nn.init
- torch.multiprocessing
- torch.legacy
- torch.cuda
- torch.utils.ffi
- torch.utils.data
- torch.utils.model_zoo
- torchvision
- torchvision.datasets
- torchvision.models
- torchvision.transforms
- torchvision.utils
- 致谢