Part 1 lesson1.ipynb, 'arch' parameter question

arch=resnet34
data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
learn = ConvLearner.pretrained(arch, data, precompute=True)

Could we replace the ‘resnet34’ to other model? like ‘mobilenetv2’? I changed, but failed…

You can, fast.ai has a bunch which you can call by default eg [‘resnet18’,
‘resnet34’,
‘resnet50’,
‘resnet101’,
‘resnet152’,
‘vgg16’,
‘vgg19’,
‘resnext50’,
‘resnext101’,
‘resnext101_64’,
‘wrn’,
‘inceptionresnet_2’,
‘inception_4’,
‘dn121’,
‘dn161’,
‘dn169’,
‘dn201’]

It’s also very easy to add mobilenetv2 too, you just need to find a version of it (like here https://github.com/Randl/MobileNetV2-pytorch) install this, create an instance of this model, and then load the pretrained weights (model.load_state_dict(torch.load(‘PATHFORWEIGHTS’)))

3 Likes