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

MulticlassExactMatch agnostic to 'ignore_index' #1508

Closed
ItamarChinn opened this issue Feb 14, 2023 · 3 comments · Fixed by #1540
Closed

MulticlassExactMatch agnostic to 'ignore_index' #1508

ItamarChinn opened this issue Feb 14, 2023 · 3 comments · Fixed by #1540
Assignees
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Milestone

Comments

@ItamarChinn
Copy link
Contributor

🐛 Bug

In MulticlassExactMatch, ignore_index kwarg doesn't do anything.

To Reproduce

Steps to reproduce the behavior...

>>> preds = torch.tensor([[1,1,1,2,2,2,2], [2,2,2,2,2,2,2]])
>>> target = torch.tensor([[1,1,1,2,-100,-100,-100], [1,1,2,2,-100,-100,-100]])
>>> preds
tensor([[1, 1, 1, 2, 2, 2, 2],
        [2, 2, 2, 2, 2, 2, 2]])
>>> target
tensor([[   1,    1,    1,    2, -100, -100, -100],
        [   1,    1,    2,    2, -100, -100, -100]])
>>> exact_match = MulticlassExactMatch(task='multiclass', num_classes=2, ignore_index=-100)
>>> exact_match.update(preds, target)
>>> exact_match.compute()

this should be 0.5 but it is 0

Expected behavior

I expected it to ignore the locations where my target == -100

Environment

Python 3.8.15
torchmetrics via pip '0.11.0'
torch '1.11.0+cu113'
Linux

@ItamarChinn ItamarChinn added bug / fix Something isn't working help wanted Extra attention is needed labels Feb 14, 2023
@github-actions
Copy link

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

@justusschock
Copy link
Member

Hey @ItamarChinn, thank you for your issue. This indeed doesn't look correct. would you be interested in submitting a fix?

@SkafteNicki SkafteNicki added this to the v0.12 milestone Feb 17, 2023
@SkafteNicki SkafteNicki self-assigned this Feb 17, 2023
@ItamarChinn
Copy link
Contributor Author

Hey @ItamarChinn, thank you for your issue. This indeed doesn't look correct. would you be interested in submitting a fix?

Sure

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.

3 participants