Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/models/BasicModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,19 @@ def resume(self,resume_path):

print("=> loading checkpoint '{}'".format(resume_path))
current_checkpoint = torch.load(resume_path)

# patch parameter name with intermediate module.
new_stat = {}
for key, val in current_checkpoint['state_dict'].items():
if "module" not in key:
new_key = key.split(".")
new_key.insert(1, "module")
new_key = ".".join(new_key)
new_stat[new_key] = val
else:
new_stat[key] = val
current_checkpoint['state_dict'] = new_stat

if isinstance(current_checkpoint['state_dict'], torch.nn.DataParallel):
current_checkpoint['state_dict'] = current_checkpoint['state_dict'].module

Expand Down