add a convenient generator method to Learner

This commit is contained in:
Connor Olding 2019-02-18 06:23:05 +01:00
parent 2b5798332d
commit 69e6ec3fad

View File

@ -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)