Is there a way to convert my existing model to a generic form so it can be used by anyone? Hopefully in a automated way and not me sludging through the weights manually?
Are you still able to load the checkpoint? DataParallel just hides the actual model away under the attribute module. So you can do something like this:
Haven’t tested this, but I bet something like this would work as well:
state_dict = torch.load(...)
new_state_dict = {}
for k, v in state_dict.items():
k = k.replace('module.', '') # Each weight k will be prefix with the word "module"
new_state_dict[k] = v
model = SomeModel(...)
model.load_state_dict(new_state_dict)
Thanks, we tried something similar to the second method and it “works”, but unsure if the model is accurately predicting or not. Still investigating… Thanks again!