Keras: .predict returns percentages instead of classes

You did not do anything wrong, predict has always returned the output of the model, for a classifier this has always been probabilities per class.

predict_classes is only available for Sequential models, not for Functional ones.

But there is an easy solution, you just need to take the argmax on the last dimension and you will get class indices:

y_probs = model1.predict(test_text_matrix)
y_pred  = np.argmax(y_probs, axis=-1)

Leave a Comment