"doc/git@developer.sourcefind.cn:OpenDAS/ktransformers.git" did not exist on "86ba1336a9e21339c2bc1b47548b39ec0cb7d324"
Commit fef4e002 authored by Jose Fonollosa's avatar Jose Fonollosa Committed by Facebook Github Bot
Browse files

Add missing parentheses in regex expression (#567)

Summary:
The regex pattern without parentheses is not correct. The checkpoints are not sorted in descending order
Pull Request resolved: https://github.com/pytorch/fairseq/pull/567

Differential Revision: D14404380

Pulled By: myleott

fbshipit-source-id: 98cd0cfa8c92b78a03ffbb94840bc0f7a118eca1
parent 5869385c
...@@ -325,7 +325,7 @@ def save_checkpoint(args, trainer, epoch_itr, val_loss): ...@@ -325,7 +325,7 @@ def save_checkpoint(args, trainer, epoch_itr, val_loss):
if args.keep_last_epochs > 0: if args.keep_last_epochs > 0:
# remove old epoch checkpoints; checkpoints are sorted in descending order # remove old epoch checkpoints; checkpoints are sorted in descending order
checkpoints = utils.checkpoint_paths(args.save_dir, pattern=r'checkpoint\d+\.pt') checkpoints = utils.checkpoint_paths(args.save_dir, pattern=r'checkpoint(\d+)\.pt')
for old_chk in checkpoints[args.keep_last_epochs:]: for old_chk in checkpoints[args.keep_last_epochs:]:
if os.path.lexists(old_chk): if os.path.lexists(old_chk):
os.remove(old_chk) os.remove(old_chk)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment