Reputation: 51
I am working on training a model for plant disease classification. I got 90% validation accuracy
model = Sequential()
model.add(Conv2D(filters=32, kernel_size=(3,3),input_shape=IMAGE_SHAPE, activation='relu',))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(filters=64, kernel_size=(3,3),input_shape=IMAGE_SHAPE, activation='relu',))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(filters=64, kernel_size=(3,3),input_shape=IMAGE_SHAPE, activation='relu',))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(filters=128, kernel_size=(3,3),input_shape=IMAGE_SHAPE, activation='relu',))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(128))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(n_classes))
model.add(Activation("softmax"))
I tested the model using a separate unseen dataset. The below matrix shows the result I got with the unseen dataset. When I choose random images from that dataset, sometimes none of them is predicted correctly, although the matrix shows that it has been classified correctly. Please help me to solve this. I am a newbie. To get an idea, please refer to the disease "target spot."It is predicted as "Two spider Mites two-spotted spider Mites" although in the matrix it is not predicted like that
Upvotes: 0
Views: 713
Reputation: 875
Your model clearly shows that it is over fitting. Over fitting means that model is working fine on training dataset but it is not working good on validation and test dataset. So there are many techniques to remove the over fitting of model. I am mentioning some of them here
Increase the complexity of model. Your model has only four convolution layers and one dense layer. So increase the both layers especially convolution layers.
Hyperparameter tuning
a). Which optimizer you are using. Try to use the Adam optimizer it works good most of time.
b) Try to use learning rate scheduler after some epochs change the learning rate using scheduler it will decrease the loss and increase accuracy.
c) Weight decay. Use weight decay in optimizer. It improves overfitting problem.
d) Try to use different batch size
Try with all these parameters and don't loose hope you will do it. It needs patience and trying again and again.
Good Luck
Upvotes: 1