Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[💡SUG] Add callback function hook for end of training an epoch #517

Closed
tszumowski opened this issue Nov 20, 2020 · 2 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@tszumowski
Copy link

Is your feature request related to a problem? Please describe.
I do not currently see a built-in way to assign a callback function to run after an epoch completes. This is helpful for pytorch-native capabilities as well as custom uses. For example, I use callbacks on epoch-complete for external distributed hyperparameter optimization routines.

Describe the solution you'd like
Add a callback function hook into the trainers that provides epoch index and the validation score for use externally. See context section for an example patch. I'm happy to PR it in, or feel free to take as you see appropriate.

Describe alternatives you've considered
None considered.

Additional context

I attached a patch file that adds an optional callback_fn. Note: This patch only shows it for the Trainer class, not the child classes. That is because this is for an example only. Also, if adopting this, it may be worth adding some try/except protection around the callback function so that any malformed callback behavior doesn't impact the main training process. Since that is a design decision, I didn't include it in the example.

trainer.py.patch.txt

@tszumowski tszumowski added the enhancement New feature or request label Nov 20, 2020
@chenyushuo chenyushuo self-assigned this Nov 21, 2020
@chenyushuo
Copy link
Collaborator

Thanks for your insightful commment. We'd appreciate it if you would like to PR it in branch 0.1.x. By the way, any PRs are welcome.
Note: trainer.py has been refactor in #521 , be careful to add this feature.

@tszumowski
Copy link
Author

@chenyushuo thank you for making this and the other PRs! I meant to submit them weeks ago, but I had to stop and move to a different project for a little while. Thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants