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

MinMetric produces incorrect result when used with MetricCollection and compute_groups=True #1890

Closed
tshead2 opened this issue Jul 7, 2023 · 1 comment · Fixed by #1896
Closed
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Milestone

Comments

@tshead2
Copy link

tshead2 commented Jul 7, 2023

🐛 Bug

Using MinMetric and MaxMetric in a MetricCollection with compute_groups=True, the minimum metric produces an incorrect result (it returns the maximum).

To Reproduce

Steps to reproduce the behavior...

>>> import torchmetrics
>>> m = torchmetrics.MetricCollection({
...   "training/min": torchmetrics.MinMetric(),
...   "training/max": torchmetrics.MaxMetric(),
... }, compute_groups=True)
>>> m.update(1)
>>> m.update(2)
>>> m.compute()
{'training/max': tensor(2.), 'training/min': tensor(2.)}

Expected behavior

The output from this example should be

{'training/max': tensor(2.), 'training/min': tensor(1.)}

... setting compute_groups=False produces the correct result.

Environment

  • TorchMetrics version 1.0.0, installed with pip
  • Python 3.10.8, PyTorch 2.0.0, installed with conda
  • Linux OS
@tshead2 tshead2 added bug / fix Something isn't working help wanted Extra attention is needed labels Jul 7, 2023
@github-actions
Copy link

github-actions bot commented Jul 7, 2023

Hi! thanks for your contribution!, great first issue!

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 help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants