add a convenient generator method to Learner
This commit is contained in:
parent
2b5798332d
commit
69e6ec3fad
1 changed files with 5 additions and 1 deletions
|
@ -50,13 +50,17 @@ class Learner:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def batch(self, progress): # TODO: rename
|
def batch(self, progress): # TODO: rename.
|
||||||
# interpolates rates between epochs.
|
# interpolates rates between epochs.
|
||||||
# unlike epochs, we do not store batch number as a state.
|
# unlike epochs, we do not store batch number as a state.
|
||||||
# i.e. calling next() will not respect progress.
|
# i.e. calling next() will not respect progress.
|
||||||
assert 0 <= progress <= 1
|
assert 0 <= progress <= 1
|
||||||
self.rate = self.rate_at(self._epoch + progress)
|
self.rate = self.rate_at(self._epoch + progress)
|
||||||
|
|
||||||
|
def each_epoch(self): # TODO: rename?
|
||||||
|
while self.next():
|
||||||
|
yield self.epoch
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def final_rate(self):
|
def final_rate(self):
|
||||||
return self.rate_at(self.epochs - 1e-8)
|
return self.rate_at(self.epochs - 1e-8)
|
||||||
|
|
Loading…
Add table
Reference in a new issue