No module named 'parse_config' while tryhing to load checkpoint in PyTorch

Viewed 904

I have a checkpoint file saved after training a model in Pytorch. I have to inspect it in a different module so I tried to load the checkpoint using the following code.

map_location = lambda storage, loc: storage
checkpoint = torch.load("model.pt", map_location=map_location)

But it is raising ModuleNotFoundError issue, which I couldn't find a way to resolve.

The error traceback :

Traceback (most recent call last):
  File "main.py", line 11, in <module>
    model = loadmodel(hook_feature)
  File "/home/../model_loader.py", line 21, in loadmodel
    checkpoint = torch.load(settings.MODEL_FILE, map_location=map_location)
  File "/home/../.conda/envs/envreporting/lib/python3.6/site-packages/torch/serialization.py", line 584, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "/home/../.conda/envs/envreporting/lib/python3.6/site-packages/torch/serialization.py", line 842, in _load
    result = unpickler.load()
ModuleNotFoundError: No module named 'parse_config'

I couldn't find an already existing issue relevant to this one.

1 Answers

Is it possible that you have used https://github.com/victoresque/pytorch-template for training the model ? In that case, the project also saves its config in the checkpoint and you also need to import parse_config.py file in order to load it.

Related