Keras softmax probabilities

931 Views Asked by At

I'm trying to get softmax probabilities from a net whose last layer is a softmax layer and when I use model.predict() I get classes instead probabilities. Could anyone tell how to get probabilities.

 model = Sequential() 
 model.add(Convolution2D(32, 3, 3,input_shape=(32, 32, 3))) 
 model.add(MaxPooling2D((2, 2))) 
 model.add(Dropout(0.5))
 model.add(Activation('relu'))
 model.add(Convolution2D(32, 3, 3))
 model.add(MaxPooling2D((2, 2))) 
 model.add(Dropout(0.5))
 model.add(Activation('relu'))
 model.add(Flatten())      
 model.add(Dense(128))
 model.add(Activation('relu')) 
 model.add(Dense(43)) 
 model.add(Activation('softmax'))
1

There are 1 best solutions below

0
On

Your model's outputs will be values between 0 and 1. Your model should give a vector of size 43 and the sum of all outputs will add to one.

Depending on your training, these "probabilities" will often be almost one for the selected class if similar to the training examples, showing that the model was well trained.