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

torchmetrics #4

Open
yutaro-s opened this issue Jan 4, 2023 · 0 comments
Open

torchmetrics #4

yutaro-s opened this issue Jan 4, 2023 · 0 comments

Comments

@yutaro-s
Copy link

yutaro-s commented Jan 4, 2023

Hi, thank you for sharing your code.

I am wondering if there is a bug in the evaluation of the Propaganda Meme dataset.
In the evaluation procedure, torchmetrics.F1 receives preds (and batch['labels']), but the data type of preds is Int (long).

output['f1'] = self.f1(preds, batch['labels'])

Given an Int tensor, TorchMetrics returns unexpected results as below:

>>> import torch
>>> from torchmetrics import F1Score
>>> target = torch.tensor([0, 1, 1, 0])
>>> preds = torch.tensor([0, 1, 1, 1])
>>> f1 = F1Score(mdmc_average="global")
>>> f1(preds, target)
tensor(0.7500)
>>> f1(preds.long(), target)
tensor(0.7500)
>>> f1(preds.float(), target)
tensor(0.8000)

I tested this with PyTorch v1.13.1 and TorchMetrics v0.10.0.

I didn't check the other metrics (e.g., precision and recall), but the same problem may exist.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant