selene
selene copied to clipboard
Early stopping and other parameters for learning rate scheduler
Reference Issues/PRs
Fixes #183
What does this implement/fix? Explain your changes.
- Added support for other parameters for
ReduceLROnPlateau. TheTrainModelobject has a new argumentscheduler_kwargsthat defaults to the pre-existing default parameters. User can specify other parameters as a dictionary, including through YAML config files. The kwargs get passed to the_init_trainmethod when the scheduler is created. Support for other types of schedulers was not added. - Added support for early stopping. The
TrainModelobject has a new optional argumentstopping_criteria. If specified, it is a list that must correspond to the metric and patience for stopping criteria. Whenvalidateis called, it checks to see the last time the specified metric improves on the validation set. If the metric has not improved in the specified patience period, then the logger reports a debug message that early stopping has been reached and the for loop intrain_and_validateis terminated.
What testing did you do to verify the changes in this PR?
- Created
TrainModelobjects from YAML config files that contain the new arguments. Verified thescheduleris assigned parameters specified in the config. Verified the early stopping criteria gets set as internal variables. - I had previously implemented the early stopping code as a hack in my own scripts and verified that the criteria can be reached and stops training early. Code implemented here is virtually identical to what I had used in my scripts.
Thanks so much for this PR @rfriedman22 ! Is there an example you can add to config_examples or just a code snippet you could leave here for us to add to the website for this new change? LGTM (:
Sorry for the delay @kathyxchen -- it's been a busy time lately. I've added an example config to this PR that demonstrates the new features :)