-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Change the seq of on_train_batch_end, on_batch_end & on_train_epoch_end, on_epoch_end hooks #5688
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
Change the seq of on_train_batch_end, on_batch_end & on_train_epoch_end, on_epoch_end hooks #5688
Conversation
Hello @kaushikb11! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-01-28 08:30:22 UTC |
Codecov Report
@@ Coverage Diff @@
## release/1.2-dev #5688 +/- ##
================================================
- Coverage 89% 88% -1%
================================================
Files 168 181 +13
Lines 12423 12890 +467
================================================
+ Hits 11103 11339 +236
- Misses 1320 1551 +231 |
I'd suggest we should deprecate these 2 hooks and remove them in the future. They are doing nothing different. |
thoughts? @PyTorchLightning/core-contributors |
Will had made a valid point of what if we want to do something on batch end across all three steps? We would have to duplicate the code in three methods. |
@Borda @kaushikb11 @rohitgr7 I can think of use cases for these hooks, so its better not to deprecate them. |
one can still do:
we can configure above by allowing my point here mostly users think of epoch as something that happens during training since epoch means nothing in case of validation/test. I have already seen many issues raised w.r.t to the difference between But if everyone thinks this is a good option, not a problem since I don't use this hook anymore ✌️ |
@ananyahjha93 mind share a use-case? |
@rohitgr7 Keeping both |
@ananyahjha93 it's a callback hook too: https://github.com/PyTorchLightning/pytorch-lightning/blob/50fd4879a9d4f8b83ace27ee580b7633d4746361/pytorch_lightning/callbacks/base.py#L86 both the hooks are there in I am just a little bit concerned about logging too since we allow logging in these hooks. |
@rohitgr7 I have code in swav which utilizes both callback and model hook version of this function. So, deprecating one of them will probably change a lot of code not just in our repositories but other people's repositories as well. Callbacks I would say serve a slightly different purpose at times than just calling the same function code in ModelHook's version of that method. |
yeah valid point, but one has to update the code even if we change it's behavior now. |
@rohitgr7 the reordering ideally should not change any code. Deprecating this would probably. |
I meant changing it's behavior to run irrespective of train/val/test will require a code change. Re-ordering is not a problem. |
@kaushikb11 Training hooks changes LGTM, do validation hooks have a similar ordering issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @kaushikb11, great work !
should we reorder
same for |
@rohitgr7 We could move the discussion for |
What does this PR do?
Fixes #5042
The idea is to have a sequence of hooks ending from specific to generic.
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:
Did you have fun?
Make sure you had fun coding 🙃