Created
March 26, 2021 13:13
-
-
Save BIGBALLON/fba7720e1cd19c6771add93379707e22 to your computer and use it in GitHub Desktop.
ddp->single
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
checkpoint = torch.load("resnet18.pth.tar") | |
state_dict = checkpoint["state_dict"] | |
from collections import OrderedDict | |
new_state_dict = OrderedDict() | |
for k, v in state_dict.items(): | |
name = k[7:] # remove 'module.' of dataparallel | |
new_state_dict[name] = v | |
checkpoint["state_dict"] = new_state_dict | |
torch.save(checkpoint, "resnet18_2.pth.tar") |
Author
BIGBALLON
commented
May 21, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment