Loading pytorch model (load_state_dict(torch.load('model.pth'))

I am loading a pretrained model from an existing GitHub repository using “load_state_dict”, where the model gives and error as:

model_rgb = torch.load(‘eval/pretrained_models/RgbNet.pth’)

result = unpickler.load()
ImportError: No module named ‘numpy.core._multiarray_umath’

I searched for the error and found that it may be due to the torch version difference during training and now testing process.

Is it for sure that this is due to the versions difference?

The code I am using to load the model:

pretrained_models={'RgbNet':'eval/pretrained_models/RgbNet.pth', 'RgbdNet':'eval/pretrained_models/RgbdNet.pth' , 'DepthNet':'eval/pretrained_models/DepthNet.pth' }

for tmp in ['D3Net']:
    for test_dataset in test_datasets:


# model_rgb.load_state_dict(torch.load(pretrained_models['RgbNet'])['model'])

The code that saved the trained model

        if self.p['if_save_checkpoint']:
            torch.save(pth_state, os.path.join(self.p['snapshot_path'], 'checkpoint.pth'))
        if is_best:
            torch.save(pth_state, os.path.join(self.p['snapshot_path'], 'best.pth'))

Okay this wasn’t the problem with the torch version or something.
The problem was with my numpy version and you can simply run the following command to get it done.

pip install -U numpy