Loading a .pth.tar file with fast.ai

Hi all,

I would like to load the AlexNet model trained on the Places365 dataset (link to website: https://github.com/CSAILVision/places365; direct link to model: http://places2.csail.mit.edu/models_places365/whole_alexnet_places365_python36.pth.tar). The model is a pth.tar file so I’m not exactly sure how to load it with fast.ai. I have been trying this out with the dogs vs. cats dataset from class. This is what I have done so far:

model_file = ‘/home/zachm/neuro/places365/docker/models_places/whole_alexnet_places365_python36.pth.tar’
model = torch.load(model_file, map_location=lambda storage, loc: storage, pickle_module=pickle)
PATH = ‘/home/zachm/fastai_data/dogscats/’
data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(model, 224))
learn = ConvLearner.pretrained(model, data, precompute=False)

At the last line of code, I get this error:
AttributeError: ‘bool’ object has no attribute ‘dim’

I’m not sure if this is covered later in class. I’m only on the 4th lesson. Would anybody be able to assist with this? I eventually would like to use the AlexNet pretrained on Places365 to model fMRI data for a separate project.

Sincerely,

Zach

I would also be interested in this, if anyone has insight. Thanks!

ConvLearner.pretrained takes a first argument that is a function, not a model. The function needs to return the model that you want. Take a look at the previous forum threads on how to use custom models for details.