Keras - Precision And Recall Is Greater Than 1 (multi Classification)
Solution 1:
I was able to figure this out. The above code works perfectly once you one-hot encode all the categorical labels. Also, make sure you do NOT have sparse_categorical_crossentropy as your loss function, and instead just use categorical_crossentropy.
If you wish to convert your categorical values to one-hot encoded values in Keras, you can just use this code:
from keras.utils importto_categoricaly_train= to_categorical(y_train)
The reason you have to do the above is noted in Keras documentation:
"when using the categorical_crossentropy loss, your targets should be in categorical format (e.g. if you have 10 classes, the target for each sample should be a 10-dimensional vector that is all-zeros except for a 1 at the index corresponding to the class of the sample). In order to convert integer targets into categorical targets, you can use the Keras utility to_categorical"
Post a Comment for "Keras - Precision And Recall Is Greater Than 1 (multi Classification)"