简体   繁体   English

如何提高CNN的预测准确率

[英]How to increase the prediction accuracy of CNN

I am working on training a model for plant disease classification.我正在训练 model 用于植物病害分类。 I got 90% validation accuracy我得到了 90% 的验证准确率在此处输入图像描述

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.我使用单独的看不见的数据集测试了 model。 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.您的 model 清楚地表明它过度拟合。 Over fitting means that model is working fine on training dataset but it is not working good on validation and test dataset.过度拟合意味着 model 在训练数据集上运行良好,但在验证和测试数据集上运行不佳。 So there are many techniques to remove the over fitting of model.所以有很多技术可以去除model的过拟合。 I am mentioning some of them here我在这里提到其中的一些

  1. Increase the complexity of model.增加 model 的复杂度。 Your model has only four convolution layers and one dense layer.您的 model 只有四个卷积层和一个密集层。 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.尝试使用 Adam 优化器,它在大多数情况下都能正常工作。

    b) Try to use learning rate scheduler after some epochs change the learning rate using scheduler it will decrease the loss and increase accuracy. b)尝试在某些时期使用调度器改变学习率后使用学习率调度器,这将减少损失并提高准确性。

    c) Weight decay. c) 重量衰减。 Use weight decay in optimizer.在优化器中使用权重衰减。 It improves overfitting problem.它改善了过拟合问题。

    d) Try to use different batch size d) 尝试使用不同的批量大小

  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.如果您没有更多数据集,您可以使用增强技术(在 Keras 中它是数据生成器)来增加数据集。

Try with all these parameters and don't loose hope you will do it.尝试使用所有这些参数,不要松懈,希望你能做到。 It needs patience and trying again and again.它需要耐心和一次又一次的尝试。

Good Luck祝你好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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