in src/trainer.py [0:0]
def end_epoch(self, scores):
"""
End the epoch.
"""
# stop if the stopping criterion has not improved after a certain number of epochs
if self.stopping_criterion is not None:
metric, biggest = self.stopping_criterion
assert metric in scores, metric
factor = 1 if biggest else -1
if factor * scores[metric] > factor * self.best_stopping_criterion:
self.best_stopping_criterion = scores[metric]
logger.info("New best validation score: %f" % self.best_stopping_criterion)
self.decrease_counts = 0
else:
logger.info("Not a better validation score (%i / %i)."
% (self.decrease_counts, self.decrease_counts_max))
self.decrease_counts += 1
if self.decrease_counts > self.decrease_counts_max:
logger.info("Stopping criterion has been below its best value for more "
"than %i epochs. Ending the experiment..." % self.decrease_counts_max)
exit()
for k in self.stats.keys():
if type(self.stats[k]) is list:
del self.stats[k][:]
self.save_checkpoint()
self.epoch += 1