distinguish resuming
@@ -23,8 +23,9 @@ class ManualScheduleTrigger(object):
"""
def __init__(self, points, unit):
- self.points = (points if isinstance(points, list) else [points])
assert unit == 'epoch' or unit == 'iteration'
+ self.prev_epoch = 0
+ self.points = (points if isinstance(points, list) else [points])
self.unit = unit
self.valid = [True] * len(self.points)
@@ -44,12 +45,15 @@ class ManualScheduleTrigger(object):
updater = trainer.updater
if self.unit == 'epoch':
- flag = [updater.epoch_detail >= p and v for (p, v) in
- six.moves.zip(self.points, self.valid)]
+ cur_epoch = updater.epoch_detail
+ th = cur_epoch - self.prev_epoch if self.prev_epoch > 0 else 0
+ flag = [p <= cur_epoch < p + th and v for (p, v)
+ in six.moves.zip(self.points, self.valid)]
ans = any([f and v for (f, v) in six.moves.zip(flag,
self.valid)])
self.valid = [not f and v for (f, v) in six.moves.zip(flag,
self.valid)]
+ self.prev_epoch = cur_epoch
return ans
else:
iteration = updater.iteration
