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

to_categorical should go before get_num_classes in metrics/functional/classification.py #2768

Closed
pwwang opened this issue Jul 30, 2020 · 2 comments · Fixed by #2781
Closed
Labels
bug Something isn't working

Comments

@pwwang
Copy link
Contributor

pwwang commented Jul 30, 2020

https://github.com/PyTorchLightning/pytorch-lightning/blob/d18b9ef9d95ffd92591f767808cc497af5bd4e1c/pytorch_lightning/metrics/functional/classification.py#L174-L178

to_categorical should go before get_num_classes, since get_num_classes assumes pred has already been turned into categories (it is doing int(pred.max().detach().item() + 1)).

Warnings are raised now and then with current code, for example:

UserWarning: You have set 10 number of classes if different from predicted (xx) and target (10) number of classes

If logits are passed in directly for metrics.

@github-actions
Copy link
Contributor

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

@Borda Borda added bug Something isn't working Metrics labels Jul 31, 2020
@Borda
Copy link
Member

Borda commented Jul 31, 2020

@pwwang mind send a PR? 🐰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants