简体   繁体   English

训练精度高 测试精度差

[英]High train accuracy poor test accuracy

I have a neural network which classify 3 output.My dataset is very small, I have 340 images for train, and 60 images for test.我有一个神经网络,可以对 3 个 output 进行分类。我的数据集非常小,我有 340 个训练图像和 60 个测试图像。 I build a model and when I compile at my result is this:我构建了一个 model ,当我编译时我的结果是这样的:

Epoch 97/100 306/306 [==============================] - 46s 151ms/step - loss: 0.2453 - accuracy: 0.8824 - val_loss: 0.3557 - val_accuracy: 0.8922 Epoch 98/100 306/306 [==============================] - 47s 152ms/step - loss: 0.2096 - accuracy: 0.9031 - val_loss: 0.3795 - val_accuracy: 0.8824 Epoch 99/100 306/306 [==============================] - 47s 153ms/step - loss: 0.2885 - accuracy: 0.8627 - val_loss: 0.4501 - val_accuracy: 0.7745 Epoch 100/100 306/306 [==============================] - 46s 152ms/step - loss: 0.1998 - accuracy: 0.9150 - val_loss: 0.4586 - val_accuracy: 0.8627纪元 97/100 306/306 [===============================] - 46 秒 151 毫秒/步 - 损失:0.2453 - 准确度: 0.8824 - val_loss: 0.3557 - val_accuracy: 0.8922 纪元 98/100 306/306 [=============================] - 47s 152ms/step - loss: 0.2096 - accuracy: 0.9031 - val_loss: 0.3795 - val_accuracy: 0.8824 Epoch 99/100 306/306 [===================== ========] - 47s 153ms/步 - 损失:0.2885 - 准确度:0.8627 - val_loss:0.4501 - val_accuracy:0.7745 Epoch 100/100 306/306 [============ ==================] - 46 秒 152 毫秒/步 - 损失:0.1998 - 准确度:0.9150 - val_loss:0.4586 - val_accuracy:0.8627

when I predict the test images, test accuracy is poor.当我预测测试图像时,测试准确性很差。 What should I do?我应该怎么办? I also use ImageDatagenerator for data augmentation but the result is same.Is it because I have small dataset.我也使用 ImageDatagenerator 进行数据扩充,但结果是一样的。是因为我的数据集很小。

You can use Regularization on fully connected layers.您可以在完全连接的层上使用正则化。 But the fact that you already have high validation accuracy it's probably your data.但事实上您已经拥有很高的验证准确性,这可能是您的数据。 your train data might not fully represent your test data.您的火车数据可能无法完全代表您的测试数据。 try to analyze that and make sure you do all the pre processing on the test data before testing as you did for the train data.尝试分析它,并确保在测试之前对测试数据进行所有预处理,就像对训练数据所做的那样。

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

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