Skip to content

torchmetrics #4

Description

@yutaro-s

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions