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

Improve error when resuming training with a different model architecture

parent d74f200a
Loading
Loading
Loading
Loading
+4 −0
Changes for fairseq/utils.py: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -96,7 +96,11 @@ def load_state(filename, model, criterion, optimizer, lr_scheduler, cuda_device=
    state = _upgrade_state_dict(state)

    # load model parameters
    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
    optim_history = state['optimizer_history']