How to get percentage of softmac

So i was following Transfer Learning for Computer Vision Tutorial — PyTorch Tutorials 1.11.0+cu102 documentation to make my program. The problem I am having is dealing with images with out the target, eg. a blank picture of idk grass. Currently t he program thinks everything is the target class. So i decided to print the probality of it being that class as a percentage.
This is my current code:
outputs = model(inputs)
print(nn.functional.softmax(outputs, dim=1))
The result is this:
tensor([[1.0000e+00, 2.2341e-06],
[1.0000e+00, 2.7773e-06],
[1.0000e+00, 3.9080e-06],
[9.9999e-01, 5.0023e-06]])
My question is: How do i turn theese numebrs into percentages

These numbers are already in percentages (1.0000e+00 ≈ 1 = 100% / 2.2341e-06 ≈ 0 = 0%). If you wanted to see it more clearly, then you could multiply them by 100.

print(nn.functional.softmax(outputs, dim=1) * 100)

As you mentioned, the model is predicting everything to be the first class with almost 100% certainty.

There are some reasons that this might happen:

  • Unbalanced Dataset
  • Not enough training time
  • Wrong hyperparameters (e.g. learning rate too high)
  • Training data not shuffled
  • “Dying ReLU”
  • Forgot to preprocesses images

If you are sure that you do not have an unbalanced dataset, then you could take a small subset of your dataset and overfit your model. This way you will see if the model is capable of learning on your dataset.