No epoch checkpoints
@@ -17,8 +17,8 @@ from cli.utils import osutils
from cli.utils.osutils import ShellError
-def _last_n_checkpoints(path, n, regex):
- pt_regexp = re.compile(regex)
+def _last_n_checkpoints(path, n):
+ pt_regexp = re.compile(r'checkpoint_\d+_(\d+)\.pt')
files = os.listdir(path)
entries = []
@@ -160,10 +160,7 @@ class TrainActivity(StatefulActivity):
@activitystep('Averaging checkpoints')
def avg_checkpoints(self):
- checkpoints = _last_n_checkpoints(self.state.nn_path, self.args.num_checkpoints, r'checkpoint_\d+_(\d+)\.pt')
- if len(checkpoints) == 0:
- # by epoch
- checkpoints = _last_n_checkpoints(self.state.nn_path, self.args.num_checkpoints, r'checkpoint(\d+)\.pt')
+ checkpoints = _last_n_checkpoints(self.state.nn_path, self.args.num_checkpoints)
if len(checkpoints) == 0:
raise ValueError('no checkpoints found in ' + self.state.nn_path)
@@ -271,8 +268,8 @@ def parse_extra_argv(parser, extra_argv):
cmd_extra_args.extend(['--save-interval-updates', '1000'])
if not argv_has(cmd_extra_args, '--keep-interval-updates'):
cmd_extra_args.extend(['--keep-interval-updates', '10'])
- if not argv_has(cmd_extra_args, '--keep-last-epochs'):
- cmd_extra_args.extend(['--keep-last-epochs', '10'])
+ if not argv_has(cmd_extra_args, '--no-epoch-checkpoints') and not argv_has(cmd_extra_args, '--keep-last-epochs'):
+ cmd_extra_args.append('--no-epoch-checkpoints')
return cmd_extra_args
