Home > Net >  How can I calculate confidence level of my ML Model for each Image of ResNet9
How can I calculate confidence level of my ML Model for each Image of ResNet9

Time:10-12

I made the ML Model using the Resnet9 algorithm. In this model, I have 38 classes. After the prediction, It returns the tuple like this:

enter image description here

It is returning negative values. In the above case, the highest value is -204.0966 means it has the highest chance of being the correct one.

I want to make it in percentage to see what the confidence(Accuracy) of that image. If anyone wants to see the code please tell me.

CodePudding user response:

You should apply the softmax function, which maps vector values to values that sum to 1 (it's a way to get a probability distribution) and multiplies the result by 100 to get percentages:

import torch
torch.nn.functional.softmax(model_output) * 100

Softmax @ Wikipedia

  • Related