We provide pre-trained models, using the PyTorch [`torch.utils.model_zoo`](../model_zoo.html#module-torch.utils.model_zoo"torch.utils.model_zoo"). These can be constructed by passing `pretrained=True`:
Instancing a pre-trained model will download its weights to a cache directory. This directory can be set using the `TORCH_MODEL_ZOO` environment variable. See [`torch.utils.model_zoo.load_url()`](../model_zoo.html#torch.utils.model_zoo.load_url"torch.utils.model_zoo.load_url") for details.
Some models use modules which have different training and evaluation behavior, such as batch normalization. To switch between these modes, use `model.train()` or `model.eval()` as appropriate. See [`train()`](../nn.html#torch.nn.Module.train"torch.nn.Module.train") or [`eval()`](../nn.html#torch.nn.Module.eval"torch.nn.Module.eval") for details.
All pre-trained models expect input images normalized in the same way, i.e. mini-batches of 3-channel RGB images of shape (3 x H x W), where H and W are expected to be at least 224. The images have to be loaded in to a range of [0, 1] and then normalized using `mean = [0.485, 0.456, 0.406]` and `std = [0.229, 0.224, 0.225]`. You can use the following transform to normalize:
所有的预训练模型都要求输入图片以相同的方式进行标准化,即:小批(mini-batch)三通道RGB格式(3 x H x W),其中H和W不得小于224。图片加载时像素值的范围应在[0, 1]内,然后通过指定`mean = [0.485, 0.456, 0.406]`和`std = [0.229, 0.224, 0.225]`进行标准化,例如:
An example of such normalization can be found in the imagenet example [here](https://github.com/pytorch/examples/blob/42e5b996718797e45c46a25c55b031e6768f8440/imagenet/main.py#L89-L101)
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
VGG 11-layer model (configuration “A”) with batch normalization
VGG11模型,带有批标准化。(论文中的“A”模型)
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
VGG 13-layer model (configuration “B”) with batch normalization
VGG13模型,带有批标准化。(论文中的“B”模型)
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
VGG 16-layer model (configuration “D”) with batch normalization
VGG16模型,带有批标准化。(论文中的“D”模型)
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
VGG 19-layer model (configuration ‘E’) with batch normalization
VGG19模型,带有批标准化。(论文中的“E”模型)
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
SqueezeNet model architecture from the [“SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size”](https://arxiv.org/abs/1602.07360) paper.
SqueezeNet模型,参见论文[《SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size》](https://arxiv.org/abs/1602.07360)。
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
SqueezeNet 1.1 model from the [official SqueezeNet repo](https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1). SqueezeNet 1.1 has 2.4x less computation and slightly fewer parameters than SqueezeNet 1.0, without sacrificing accuracy.
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |
Inception v3 model architecture from [“Rethinking the Inception Architecture for Computer Vision”](http://arxiv.org/abs/1512.00567).
Inception v3模型,参见[《Rethinking the Inception Architecture for Computer Vision》](http://arxiv.org/abs/1512.00567)。
| Parameters: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool"(in Python v3.7)")) – If True, returns a model pre-trained on ImageNet |