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

Unqualified threshold checks contradict logits support #369

Closed
MichaelSpece opened this issue Jul 13, 2021 · 4 comments · Fixed by #401
Closed

Unqualified threshold checks contradict logits support #369

MichaelSpece opened this issue Jul 13, 2021 · 4 comments · Fixed by #401
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Milestone

Comments

@MichaelSpece
Copy link

🐛 Bug

Accuracy both functional and module-wise are currently designed to accommodate logits. However, the most natural choice of a threshold (0) fails in both cases. More generally, thresholds outside of (0, 1) trigger ValueError. This is documented behavior that contradicts logits support.

To Reproduce

Code sample

torchmetrics.functional.classification.accuracy(torch.tensor([0]), torch.tensor([1]), threshold=0)

or

torchmetrics.classification.accuracy.Accuracy(threshold=0)

Expected behavior

Ability to choose arbitrary float thresholds without triggering an exception.

Environment

Bugs are apparent from the source code itself. The threshold checks are unqualified.

Additional context

Predictions are formed from a given preds via preds >= threshold.

Threshold checks were recently removed for F1 (#350, #351) to support logits.

Open to assignment.

@MichaelSpece MichaelSpece added bug / fix Something isn't working help wanted Extra attention is needed labels Jul 13, 2021
@github-actions
Copy link

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

@SkafteNicki
Copy link
Member

Fixed in PR #351, please update to master:

pip install git+https://github.com/PytorchLightning/metrics.git@master

Closing issue.

@SkafteNicki SkafteNicki reopened this Jul 22, 2021
@SkafteNicki
Copy link
Member

Hi @MichaelSpece, thanks for making me aware that the code indeed is not updated everywhere.

@Borda Borda added this to the v0.5 milestone Aug 18, 2021
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