简体   繁体   中英

How to increase the prediction accuracy of CNN

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混淆矩阵 预言

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

  1. Increase the complexity of model. Your model has only four convolution layers and one dense layer. So increase the both layers especially convolution layers.

  2. 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

  1. Increase your dataset. If you dont have more dataset you can use the augmentation technique (in Keras it is datagenerator) to increase the dataset.

Try with all these parameters and don't loose hope you will do it. It needs patience and trying again and again.

Good Luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM