Skip to content

Commit

Permalink
Merge pull request OpenNMT#614 from pltrdy/remove_optim
Browse files Browse the repository at this point in the history
Removing optimizer from model file
  • Loading branch information
srush authored Mar 21, 2018
2 parents 0415768 + e312426 commit 5cd11fa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tools/release_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
import argparse
import torch

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Removes the optim data of PyTorch models")
parser.add_argument("--model", "-m",
help="The model filename (*.pt)", required=True)
parser.add_argument("--output", "-o",
help="The output filename (*.pt)", required=True)
opt = parser.parse_args()

model = torch.load(opt.model)
model['optim'] = None
torch.save(model, opt.output)

0 comments on commit 5cd11fa

Please sign in to comment.