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

How to get the probablity in each multiclass? #49

Closed
jerronl opened this issue Apr 24, 2023 · 1 comment
Closed

How to get the probablity in each multiclass? #49

jerronl opened this issue Apr 24, 2023 · 1 comment

Comments

@jerronl
Copy link

jerronl commented Apr 24, 2023

other than the max bucket from argmax, can we also have the probabilities for each class? currently the prediction often have a lot negative values and I don't know what would be the right way to convert them to probabilities.

@Yura52
Copy link
Collaborator

Yura52 commented Apr 24, 2023

The predictions are logits. To convert them to probabilities, use softmax:

import torch.nn.functional as F

logits = model(x)
probabilities = F.softmax(logits, dim=-1)

@Yura52 Yura52 closed this as completed Apr 30, 2023
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

2 participants