-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[Metrics] Disable default reset after compute #5409
[Metrics] Disable default reset after compute #5409
Conversation
Hello @SkafteNicki! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-01-13 08:42:24 UTC |
hmm ddp tests seem to be failing, looking into it now |
DDP tests broke as we were writing to Now just need to fix |
Second bug was a little more tricky. When the results object computes metrics, there can be duplicates of the same metric under a different name e.g. |
Codecov Report
@@ Coverage Diff @@
## release/1.2-dev #5409 +/- ##
================================================
Coverage 93% 93%
================================================
Files 151 151
Lines 10645 10824 +179
================================================
+ Hits 9859 10043 +184
+ Misses 786 781 -5 |
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.
Great job !
self[k].compute() | ||
self[k].reset() |
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.
Why reset is being added there ? self[k].compute()
and self[k].reset()
makes compute()
useless no ?
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.
compute()
will save the computed value to self._computed
, so if compute()
is called again without any update()
call, the cached value will be provided. We still call reset()
so that we don't get too much memory usage by needlessly accumulating tensors over epochs.
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.
This is important if we have a metric that is logged on both step and epoch. Since it will show up twice in the results meta dict, we want to reset the step metric on epoch end, but still allow the epoch metric to be computed.
Co-authored-by: Roger Shieh <[email protected]>
* reset * self._cache -> cache (make cache local variable so it is not overwritten) * pep8 * fix metric result integration * rm print statements * better comment * changelog * Update docs/source/metrics.rst Co-authored-by: Roger Shieh <[email protected]> Co-authored-by: Teddy Koker <[email protected]> Co-authored-by: Roger Shieh <[email protected]>
What does this PR do?
Rework of #5193
Fixes #5166
Fixes #4641
This PR removes the automatic
reset
that happens aftercompute
for metrics (solution proposed by @teddykoker here #5193 (comment)). This give the user more control over when to actually reset the state but also put a bit more responsibility on user as the they would need to reset the metric themself between epochs (except if they use metrics together withself.log
, then we still auto reset between epochs for them).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 🙃