From 69e6ec3fadfd443165f2c7a2cc01718d7a3cadb5 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Mon, 18 Feb 2019 06:23:05 +0100 Subject: [PATCH] add a convenient generator method to Learner --- onn/learner.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/onn/learner.py b/onn/learner.py index f4e0bb6..fc2ba38 100644 --- a/onn/learner.py +++ b/onn/learner.py @@ -50,13 +50,17 @@ class Learner: return False return True - def batch(self, progress): # TODO: rename + def batch(self, progress): # TODO: rename. # interpolates rates between epochs. # unlike epochs, we do not store batch number as a state. # i.e. calling next() will not respect progress. assert 0 <= progress <= 1 self.rate = self.rate_at(self._epoch + progress) + def each_epoch(self): # TODO: rename? + while self.next(): + yield self.epoch + @property def final_rate(self): return self.rate_at(self.epochs - 1e-8)