Hello everyone,
I am facing the following issue:
I have a saved model, that i once trained with fastai1.
The architecture is torchvision.models.resnet.resnext101_32x8d
Now I am trying to load the weights of that model to a learner in fastai2.
I am using the exact same architecture.
Unfortunately it is not working and I get the following error:
RuntimeError Traceback (most recent call last)
in
----> 1 learner.load(model_path)
/opt/conda/envs/DLM_Py3/lib/python3.7/site-packages/fastai2/learner.py in load(self, file, with_opt, device, **kwargs)
271 if self.opt is None: self.create_opt()
272 file = join_path_file(file, self.path/self.model_dir, ext=’.pth’)
–> 273 load_model(file, self.model, self.opt, device=device, **kwargs)
274 return self
275
/opt/conda/envs/DLM_Py3/lib/python3.7/site-packages/fastai2/learner.py in load_model(file, model, opt, with_opt, device, strict)
52 hasopt = set(state)=={‘model’, ‘opt’}
53 model_state = state[‘model’] if hasopt else state
—> 54 get_model(model).load_state_dict(model_state, strict=strict)
55 if hasopt and ifnone(with_opt,True):
56 try: opt.load_state_dict(state[‘opt’])
/opt/conda/envs/DLM_Py3/lib/python3.7/site-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict)
828 if len(error_msgs) > 0:
829 raise RuntimeError(‘Error(s) in loading state_dict for {}:\n\t{}’.format(
–> 830 self.class.name, “\n\t”.join(error_msgs)))
831 return _IncompatibleKeys(missing_keys, unexpected_keys)
832
RuntimeError: Error(s) in loading state_dict for Sequential:
Unexpected key(s) in state_dict: “1.4.bias”, “1.8.bias”.
Can someone give me a tip on how to solve this issue?
Thanks a lot in advance!
Christoph