7.5 使用MobileNet v3进行图像的区分
MobileNet v3是Google在2019年提出的轻量级卷积神经网络结构,旨在提高在移动设备上的速度和准确性,广泛的用于轻量级网络。
MobileNet v3-Small的网络结构如下,它的输入是224x224的3通道彩色图片。
使用过程如下:
1.创建模型、修改最终分类数量
#1.创建mobilenet_v3_small 模型
self.model = torchvision.models.mobilenet_v3_small(pretrained=True)
# 2.修改分类数量(二分类)
self.model.classifier[3] = nn.Linear(self.model.classifier[3].in_features, num_class) # 修改最后一层
# 3.将模型移动到指定的计算设备