-1

in a model I have trained I am applying softmax function in the output layer of the neural network. the output has 41 categories and I want to fetch the label with max value and the value itself ..i. e in the output. 41 diseases for a set of inputs ....the softmax predicts for all the diseases but I want to print the disease with maximum probability along with the probability how do I do it?

Arjun Tiwari
  • 1
  • 1
  • 1

1 Answers1

2

You can achieve this by simply using the np.argmax() function :

For example, to get the index of the disease with maximum probability of your first test example :

predictions = model.predict(x_test)
print(np.argmax(predictions[0])  #output the index of the disease with max proba
                                 #for example N#0
Thibault Bacqueyrisses
  • 2,281
  • 1
  • 6
  • 18