PyTorch 1.0 中文文档:torchvision.models

2022-05-07 14:24:58 浏览数 (1)

译者:BXuan694

models子包定义了以下模型架构:

  • AlexNet
  • VGG
  • ResNet
  • SqueezeNet
  • DenseNet
  • Inception v3

你可以通过调用以下构造函数构造随机权重的模型:

代码语言:javascript复制
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()

我们在torch.utils.model_zoo中提供了预训练模型。预训练模型可以通过传递参数pretrained=True构造:

代码语言:javascript复制
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)

阅读全文/改进本文

0 人点赞