Skip to content

Commit

Permalink
only change model keys of key name starts with 'model'
Browse files Browse the repository at this point in the history
  • Loading branch information
laurahanu committed Sep 3, 2021
1 parent 8d5b1cf commit 5700981
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions convert_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def main():
"config": checkpoint["hyper_parameters"]["config"],
}
for k, v in checkpoint["state_dict"].items():
name = k[6:] # remove `model.`
new_state_dict["state_dict"][name] = v
if k.startswith("model."):
k = k[6:] # remove `model.`
new_state_dict["state_dict"][k] = v

torch.save(new_state_dict, ARGS.save_to)

Expand Down

0 comments on commit 5700981

Please sign in to comment.