marcman411:

KeyError: ‘unexpected key “module.feature_extractor.conv_block1.0.weight” in state_dict’


Nevermind, this is answered here:

  
    
    
    [solved] KeyError: 'unexpected key "module.encoder.embedding.weight" in state_dict' 
  
  
    I am getting the following error while trying to load a saved model. 
KeyError: 'unexpected key "module.encoder.embedding.weight" in state_dict' 
This is the function I am using to load a saved model. (as suggested in http://pytorch.org/docs/notes/serialization.html#recommend-saving-models) 
def load_model_states(model, tag):
    """Load a previously saved model states."""
    filename = os.path.join(args.save_path, tag)
    with open(filename, 'rb') as f:
        model.load_state_dict(torch.loa…