Skip to content

KeyError in load_model() #717

@ManuelZ

Description

@ManuelZ

This line is generating a RuntimeError:

RuntimeError: Error(s) in loading state_dict for DataParallel:
Missing key(s) in state_dict: "module.conv1.weight", "module.bn1.weight", ...

This happened after running this example, replacing trainer.train(num_epochs=num_epochs) by;

start_epoch = hooks.load_latest_saved_models(trainer, model_folder, device)
trainer.train(start_epoch, num_epochs=num_epochs)

And running trainer.train(start_epoch, num_epochs=num_epochs) a second time.

Also note that I ran the example:

  • Without pip install pytorch-metric-learning[with-hooks] because that downgraded my PML.
  • With dataloader_num_workers=0.

PyTorch version: 2.4.1+cu121
PyTorch Metric Learning version: 2.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions