Commit be274623 authored by Myle Ott's avatar Myle Ott
Browse files

Improve error when resuming training with a different model architecture

parent d74f200a
...@@ -96,7 +96,11 @@ def load_state(filename, model, criterion, optimizer, lr_scheduler, cuda_device= ...@@ -96,7 +96,11 @@ def load_state(filename, model, criterion, optimizer, lr_scheduler, cuda_device=
state = _upgrade_state_dict(state) state = _upgrade_state_dict(state)
# load model parameters # load model parameters
model.load_state_dict(state['model']) try:
model.load_state_dict(state['model'])
except:
raise Exception('Cannot load model parameters from checkpoint, '
'please ensure that the architectures match')
# only load optimizer and lr_scheduler if they match with the checkpoint # only load optimizer and lr_scheduler if they match with the checkpoint
optim_history = state['optimizer_history'] optim_history = state['optimizer_history']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment