Add snapshot frequency option to mnist example
@@ -40,6 +40,8 @@ def main():
help='Number of images in each mini-batch')
parser.add_argument('--epoch', '-e', type=int, default=20,
help='Number of sweeps over the dataset to train')
+ parser.add_argument('--frequency', '-f', type=int, default=20,
+ help='Frequency of taking a snapshot')
parser.add_argument('--gpu', '-g', type=int, default=-1,
help='GPU ID (negative value indicates CPU)')
parser.add_argument('--out', '-o', default='result',
@@ -86,8 +88,8 @@ def main():
# The "main" refers to the target link of the "main" optimizer.
trainer.extend(extensions.dump_graph('main/loss'))
- # Take a snapshot at each epoch
- trainer.extend(extensions.snapshot(), trigger=(args.epoch, 'epoch'))
+ # Take a snapshot for each specified epoch
+ trainer.extend(extensions.snapshot(), trigger=(args.frequency, 'epoch'))
# Write a log of evaluation statistics for each epoch
trainer.extend(extensions.LogReport())
