tensorflow version = '1.12.0'
keras version = '2.1.6-tf'
I'm using keras with tensorflow backend.
I want to get the probabilities values of the prediction. I want the probabilities to sum up to 1. I tried using 'softmax' and 'categorical_crossentropy' but nothing works.
This is my model:
X = pickle.load(open("X.pickle", "rb"))
y = pickle.load(open("y.pickle", "rb"))
number_of_gestures = 5
y = to_categorical(y, num_classes=number_of_gestures) #to_categorical is a function from keras - np_utils.
model = Sequential()
model.add(Conv2D(16, (2,2), input_shape=(IMG_SIZE, IMG_SIZE, 1), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding='same'))
model.add(Conv2D(32, (5,5), activation='relu'))
model.add(MaxPooling2D(pool_size=(5, 5), strides=(5, 5), padding='same'))
model.add(Conv2D(64, (5,5), activation='relu'))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(number_of_gestures, activation='softmax'))
sgd = optimizers.SGD(lr=1e-2)
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
model.fit(X, y, batch_size=500, epochs=40, validation_split=0.1)
The probabilities looks like that:
[1. 0. 0. 0. 0.]
And I want it to look like this:
[0.897. 0.023. 0.158. 0.780. 0.1021]
I know it does not sum up to 1 but this is just an example.