Classification metrics

Hello ,
I’m doing classification using recurrent network and I remember using a metric in SKlearn with random forest that gives the classifier probability of each class , example I have 3 classes this metric gives me the probability of what the classifier thinks this object belongs to which class , Is there a built in function in Pytorch that does this ?
Thank you

If your model returns logits, you could call F.softmax on them, which will yield the class probabilities.
Example:

import torch.nn.functional as F

model = nn.Linear(10, 5)
x = torch.randn(1, 10)
output = model(x)
prob = F.softmax(output, dim=1)
1 Like