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

fix: MetricCollection did not copy the inner state of the metric in ClasswiseWrapper when computing group metrics #2390

Merged
merged 7 commits into from
Mar 5, 2024

Conversation

daniel-code
Copy link
Contributor

@daniel-code daniel-code commented Feb 17, 2024

MetricCollection did not copy the inner state of the metric in ClasswiseWrapper when computing group metrics

Issue Link: #2389

What does this PR do?

Fixes #2389

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃


📚 Documentation preview 📚: https://torchmetrics--2390.org.readthedocs.build/en/2390/

@Borda Borda added the bug / fix Something isn't working label Feb 19, 2024
@Borda Borda changed the title fix: MetricCollection did not copy the inner state of the metric in ClasswiseWrapper when computing group metrics fix: MetricCollection did not copy the inner state of the metric in ClasswiseWrapper when computing group metrics Feb 19, 2024
@Borda Borda added this to the v1.3.x milestone Feb 19, 2024
@daniel-code
Copy link
Contributor Author

I find the ClasswiseWrapper should also set the _persistent and _reductions the same as the internal metric to prevent the error of state_dict.

The fix has been updated to the source branch.

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Merging #2390 (b17dbce) into master (2c2316e) will decrease coverage by 33%.
The diff coverage is 27%.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #2390     +/-   ##
========================================
- Coverage      69%     36%    -33%     
========================================
  Files         307     307             
  Lines       17348   17363     +15     
========================================
- Hits        11957    6218   -5739     
- Misses       5391   11145   +5754     

Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, @SkafteNicki @justusschock mind check pls 🐰

@mergify mergify bot added the ready label Feb 27, 2024
@SkafteNicki SkafteNicki enabled auto-merge (squash) March 5, 2024 09:01
@SkafteNicki SkafteNicki merged commit 1951a06 into Lightning-AI:master Mar 5, 2024
60 of 61 checks passed
Borda pushed a commit that referenced this pull request Mar 16, 2024
… `ClasswiseWrapper` when computing group metrics (#2390)

* fix: MetricCollection did not copy inner state of metric in ClasswiseWrapper when computing groups metrics

Issue Link: #2389

* fix: set _persistent and _reductions be same as internal metric

* test: check metric state_dict wrapped in `ClasswiseWrapper`

---------

Co-authored-by: Jirka Borovec <[email protected]>
(cherry picked from commit 1951a06)
Borda pushed a commit that referenced this pull request Mar 18, 2024
… `ClasswiseWrapper` when computing group metrics (#2390)

* fix: MetricCollection did not copy inner state of metric in ClasswiseWrapper when computing groups metrics

Issue Link: #2389

* fix: set _persistent and _reductions be same as internal metric

* test: check metric state_dict wrapped in `ClasswiseWrapper`

---------

Co-authored-by: Jirka Borovec <[email protected]>
(cherry picked from commit 1951a06)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MetricCollection did not copy inner state of metric in ClasswiseWrapper when computing groups metrics
3 participants