mobilenet_v2¶
- torchvision.models.mobilenet_v2(*, weights: Optional[MobileNet_V2_Weights] = None, progress: bool = True, **kwargs: Any) MobileNetV2 [source]¶
来自《MobileNetV2: Inverted Residuals and Linear Bottlenecks》论文的 MobileNetV2 架构。
- 参数:
weights (
MobileNet_V2_Weights
, 可选) – 要使用的预训练权重。请参阅下方的MobileNet_V2_Weights
以了解更多详细信息和可能的值。默认情况下,不使用预训练权重。progress (bool, 可选) – 如果为 True,则在标准错误输出 (stderr) 中显示下载进度条。默认值为 True。
**kwargs – 传递给
torchvision.models.mobilenetv2.MobileNetV2
基类的参数。请参阅源代码了解此类的更多详细信息。
- class torchvision.models.MobileNet_V2_Weights(value)[source]¶
上述模型构建器接受以下值作为
weights
参数。MobileNet_V2_Weights.DEFAULT
等同于MobileNet_V2_Weights.IMAGENET1K_V2
。您也可以使用字符串,例如weights='DEFAULT'
或weights='IMAGENET1K_V1'
。MobileNet_V2_Weights.IMAGENET1K_V1:
这些权重使用简单的训练方案能较好地重现论文结果。
acc@1 (在 ImageNet-1K 上)
71.878
acc@5 (在 ImageNet-1K 上)
90.286
num_params
3504872
min_size
height=1, width=1
类别
丁鲷, 金鱼, 大白鲨, ... (省略 997 个)
训练方案
GFLOPS
0.30
文件大小
13.6 MB
推理变换可在
MobileNet_V2_Weights.IMAGENET1K_V1.transforms
获取,并执行以下预处理操作:接受PIL.Image
、批处理的(B, C, H, W)
和单个(C, H, W)
图像torch.Tensor
对象。使用interpolation=InterpolationMode.BILINEAR
将图像大小调整到resize_size=[256]
,然后进行crop_size=[224]
的中心裁剪。最后,先将值重新缩放到[0.0, 1.0]
,然后使用mean=[0.485, 0.456, 0.406]
和std=[0.229, 0.224, 0.225]
进行归一化。MobileNet_V2_Weights.IMAGENET1K_V2:
这些权重通过使用 TorchVision 新训练方案的修改版本,改进了原始论文的结果。也可用作
MobileNet_V2_Weights.DEFAULT
。acc@1 (在 ImageNet-1K 上)
72.154
acc@5 (在 ImageNet-1K 上)
90.822
num_params
3504872
min_size
height=1, width=1
类别
丁鲷, 金鱼, 大白鲨, ... (省略 997 个)
训练方案
GFLOPS
0.30
文件大小
13.6 MB
推理变换可在
MobileNet_V2_Weights.IMAGENET1K_V2.transforms
获取,并执行以下预处理操作:接受PIL.Image
、批处理的(B, C, H, W)
和单个(C, H, W)
图像torch.Tensor
对象。使用interpolation=InterpolationMode.BILINEAR
将图像大小调整到resize_size=[232]
,然后进行crop_size=[224]
的中心裁剪。最后,先将值重新缩放到[0.0, 1.0]
,然后使用mean=[0.485, 0.456, 0.406]
和std=[0.229, 0.224, 0.225]
进行归一化。