# 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
- 致謝