未验证 提交 6c01f353 编写于 作者: 飞龙 提交者: GitHub

Merge pull request #320 from BXuan694/master

Add files via upload
......@@ -2,7 +2,9 @@
# torchvision.models
The models subpackage contains definitions for the following model architectures:
> 译者:[BXuan694](https://github.com/BXuan694)
models子包定义了以下模型架构:
* [AlexNet](https://arxiv.org/abs/1404.5997)
* [VGG](https://arxiv.org/abs/1409.1556)
......@@ -11,7 +13,7 @@ The models subpackage contains definitions for the following model architectures
* [DenseNet](https://arxiv.org/abs/1608.06993)
* [Inception](https://arxiv.org/abs/1512.00567) v3
You can construct a model with random weights by calling its constructor:
你可以通过调用以下构造函数构造随机权重的模型:
```py
import torchvision.models as models
......@@ -24,7 +26,7 @@ inception = models.inception_v3()
```
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`:
我们在[`torch.utils.model_zoo`](../model_zoo.html#module-torch.utils.model_zoo "torch.utils.model_zoo")中提供了预训练模型。预训练模型可以通过传递参数`pretrained=True`构造:
```py
import torchvision.models as models
......@@ -37,11 +39,11 @@ inception = models.inception_v3(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.
定义预训练模型时会把权值下载到一个缓存文件夹中,这个缓存文件可以通过环境变量`TORCH_MODEL_ZOO`来指定。更多细节见[`torch.utils.model_zoo.load_url()`](../model_zoo.html#torch.utils.model_zoo.load_url "torch.utils.model_zoo.load_url")
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.
有些模型在训练和测试阶段用到了不同的模块,例如批标准化(batch normalization)。使用`model.train()``model.eval()`可以切换到相应的模式。更多细节见[`train()`](../nn.html#torch.nn.Module.train "torch.nn.Module.train")[`eval()`](../nn.html#torch.nn.Module.eval "torch.nn.Module.eval")
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]`进行标准化,例如:
```py
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
......@@ -49,21 +51,21 @@ normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
```
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)
[imagenet的示例](https://github.com/pytorch/examples/blob/42e5b996718797e45c46a25c55b031e6768f8440/imagenet/main.py#L89-L101)中可以看到标准化的一个应用。
ImageNet 1-crop error rates (224x224)
下表是ImageNet单次224x224中心裁剪的错误率。
| Network | Top-1 error | Top-5 error |
| 网络 | Top-1错误率(%) | Top-5错误率(%) |
| --- | --- | --- |
| 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 |
| VGG-11 with batch normalization | 29.62 | 10.19 |
| VGG-13 with batch normalization | 28.45 | 9.63 |
| VGG-16 with batch normalization | 26.63 | 8.50 |
| VGG-19 with batch normalization | 25.76 | 8.15 |
| 带有批标准化的VGG-11 | 29.62 | 10.19 |
| 带有批标准化的VGG-13 | 28.45 | 9.63 |
| 带有批标准化的VGG-16 | 26.63 | 8.50 |
| 带有批标准化的VGG-19 | 25.76 | 8.15 |
| ResNet-18 | 30.24 | 10.92 |
| ResNet-34 | 26.70 | 8.58 |
| ResNet-50 | 23.85 | 7.13 |
......@@ -83,10 +85,10 @@ ImageNet 1-crop error rates (224x224)
torchvision.models.alexnet(pretrained=False, **kwargs)
```
AlexNet model architecture from the [“One weird trick…”](https://arxiv.org/abs/1404.5997) paper.
AlexNet模型,参见论文[《One weird trick…》](https://arxiv.org/abs/1404.5997)
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
## VGG
......@@ -95,80 +97,80 @@ AlexNet model architecture from the [“One weird trick…”](https://arxiv.org
torchvision.models.vgg11(pretrained=False, **kwargs)
```
VGG 11-layer model (configuration “A”)
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.vgg11_bn(pretrained=False, **kwargs)
```
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.vgg13(pretrained=False, **kwargs)
```
VGG 13-layer model (configuration “B”)
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.vgg13_bn(pretrained=False, **kwargs)
```
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.vgg16(pretrained=False, **kwargs)
```
VGG 16-layer model (configuration “D”)
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.vgg16_bn(pretrained=False, **kwargs)
```
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.vgg19(pretrained=False, **kwargs)
```
VGG 19-layer model (configuration “E”)
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.vgg19_bn(pretrained=False, **kwargs)
```
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
## ResNet
......@@ -177,50 +179,50 @@ VGG 19-layer model (configuration ‘E’) with batch normalization
torchvision.models.resnet18(pretrained=False, **kwargs)
```
Constructs a ResNet-18 model.
构造ResNet-18模型。
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.resnet34(pretrained=False, **kwargs)
```
Constructs a ResNet-34 model.
构造ResNet-34模型。
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.resnet50(pretrained=False, **kwargs)
```
Constructs a ResNet-50 model.
构造ResNet-50模型。
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.resnet101(pretrained=False, **kwargs)
```
Constructs a ResNet-101 model.
构造ResNet-101模型。
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.resnet152(pretrained=False, **kwargs)
```
Constructs a ResNet-152 model.
构造ResNet-152模型。
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
## SqueezeNet
......@@ -229,20 +231,20 @@ Constructs a ResNet-152 model.
torchvision.models.squeezenet1_0(pretrained=False, **kwargs)
```
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.squeezenet1_1(pretrained=False, **kwargs)
```
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.
SqueezeNet 1.1模型,参见[SqueezeNet官方仓库](https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1)。SqueezeNet 1.1比SqueezeNet 1.0节约2.4倍的计算量,参数也略少,然而精度未做牺牲。
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
## DenseNet
......@@ -251,40 +253,40 @@ SqueezeNet 1.1 model from the [official SqueezeNet repo](https://github.com/Deep
torchvision.models.densenet121(pretrained=False, **kwargs)
```
Densenet-121 model from [“Densely Connected Convolutional Networks”](https://arxiv.org/pdf/1608.06993.pdf)
Densenet-121模型,参见[《Densely Connected Convolutional Networks》](https://arxiv.org/pdf/1608.06993.pdf)
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.densenet169(pretrained=False, **kwargs)
```
Densenet-169 model from [“Densely Connected Convolutional Networks”](https://arxiv.org/pdf/1608.06993.pdf)
Densenet-169模型,参见[《Densely Connected Convolutional Networks》](https://arxiv.org/pdf/1608.06993.pdf)
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.densenet161(pretrained=False, **kwargs)
```
Densenet-161 model from [“Densely Connected Convolutional Networks”](https://arxiv.org/pdf/1608.06993.pdf)
Densenet-161模型,参见[《Densely Connected Convolutional Networks》](https://arxiv.org/pdf/1608.06993.pdf)
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
```py
torchvision.models.densenet201(pretrained=False, **kwargs)
```
Densenet-201 model from [“Densely Connected Convolutional Networks”](https://arxiv.org/pdf/1608.06993.pdf)
Densenet-201模型,参见[《Densely Connected Convolutional Networks》](https://arxiv.org/pdf/1608.06993.pdf)
| 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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
## Inception v3
......@@ -293,9 +295,8 @@ Densenet-201 model from [“Densely Connected Convolutional Networks”](https:/
torchvision.models.inception_v3(pretrained=False, **kwargs)
```
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 |
| 参数: | **pretrained** ([_bool_](https://docs.python.org/3/library/functions.html#bool "(in Python v3.7)")) – 如果设置为True,返回ImageNet预训练模型 |
| --- | --- |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册