I was following a tutorial to learn train a classifier using Keras
https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html
Use softmax
as activation function of the output layer, it is a generalization of the logistic function for a multi class case. Read more about it here.
If validation error is much greater than the training one, as in your case, it is an indicator of overfitting. You should do some regularization, which is defined as any changes of the learning algorithm, that are intended to reduce the test error but not the training one. You can try things like data augmentation, early stopping, noise injection, more aggressive dropout, etc.
If you have the same set-up as in the linked tutorial, change the class_mode
of the train_generator
and validation_generator
to categorical
and it will one-hot encode your classes.