delu.ProgressTracker¶
- class delu.ProgressTracker(patience, min_delta=0.0)[source]¶
Tracks the best score, helps with early stopping.
For
ProgressTracker
, the greater score is the better score. At any moment the tracker is in one of the following states:success: the last update changed the best score
fail: last
n > patience
updates are not better than the best scoreneutral: if neither success nor fail
Tutorial
progress = ProgressTracker(2) progress.update(-999999999) assert progress.success # the first update always updates the best score progress.update(123) assert progress.success assert progress.best_score == 123 progress.update(0) assert not progress.success and not progress.fail progress.update(123) assert not progress.success and not progress.fail progress.update(123) # patience is 2 and the best score is not updated for more than 2 steps assert progress.fail assert progress.best_score == 123 # fail doesn't affect the best score progress.update(123) assert progress.fail # still no improvements progress.forget_bad_updates() assert not progress.fail and not progress.success assert progress.best_score == 123 progress.update(0) assert not progress.fail # just 1 bad update (the patience is 2) progress.reset() assert not progress.fail and not progress.success assert progress.best_score is None
Attributes
The best score so far.
Check if the tracker is in the 'fail' state.
Check if the tracker is in the 'success' state.
Methods
Initialize self.
Reset bad updates and status, but not the best score.
Reset everything.
Update the tracker's state.