简体   繁体   English

训练准确度好但验证准确度差

[英]Good training accuracy but poor validation accuracy

I am trying to implement a residual network to classify images on the CIFAR10 dataset for a project and I have a working model that has an accuracy that logarthimically grows, but a validation accuracy that plateaus.我正在尝试实现一个残差网络来对一个项目的 CIFAR10 数据集上的图像进行分类,我有一个工作模型,它的准确性以对数方式增长,但验证准确性却停滞不前。 I used batch normalization and relu after most layers and used a softmax at the end.我在大多数层之后使用了批量归一化和 relu,并在最后使用了 softmax。

Here is my data split:这是我的数据拆分:

(train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data()

Here is my code to compile and train the model这是我编译和训练模型的代码

resNet50.compile(optimizer='adam',loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),metrics=['accuracy'])
resNet50.fit(train_images, train_labels, epochs=EPOCHS, validation_data=(test_images, test_labels))

在此处输入图片说明

在此处输入图片说明

What might be causing this validation plateau and what could improve my model?什么可能导致这种验证平台以及什么可以改进我的模型?

Thank you in advanced for your feedback and comments.提前感谢您的反馈和评论。

This is a very common problem, that is a form of overfitting.这是一个非常常见的问题,即过度拟合的一种形式。

I invite you to read the book Deep Learning by Ian Goodfellow and Yoshua Bengio and Aaron Courville, especially this chapter (in free access), that's very informative.我邀请您阅读 Ian Goodfellow、Yoshua Bengio 和 Aaron Courville 所著的深度学习一书,尤其是这一章(免费访问),内容非常丰富。

In short, you seem to have chosen a model (ResNet50 + default training parameters) that has too much capacity for your problem and data.简而言之,您似乎选择了一个模型(ResNet50 + 默认训练参数)对您的问题和数据容量太大。 If you choose a model that is too simple, you'll get the training and evaluation curves very close to one another, but with worse performance that what you could achieve.如果您选择的模型太简单,您将获得非常接近的训练和评估曲线,但性能会比您所能达到的更差。 If you choose a model that is too complex (as is a bit the case here), you can reach a much better performance on the training data, but the eval will not be at the same level, and could even be quite bad.如果您选择的模型过于复杂(就像这里的情况一样),您可以在训练数据上获得更好的性能,但 eval 不会处于同一水平,甚至可能非常糟糕。 That's called overfitting on the training set.这称为训练集上的过度拟合

What you want is the best middle point : the best performance on evaluation data is found with a model complexity that's just before overfitting : you want the two performance curves to be close one to another, but both should be as good as possible.你想要的是最好的中间点:最好的评估数据性能是在模型复杂度刚刚过拟合之前找到的:你希望两条性能曲线彼此接近,但两者都应该尽可能好。

So you need to decrease the capacity of your model for your problem.因此,您需要针对您的问题降低模型的容量。 There are different ways to do that, they will not be equally efficient in terms of reducing overfitting, nor in terms of decreasing your train performance.有不同的方法可以做到这一点,它们在减少过度拟合和降低火车性能方面的效率不同。 The best method is usually to add more training data, if you can.如果可以,最好的方法通常是添加更多的训练数据。 If you can't, the next good things to add is regularization , such as data augmentation, dropout , L1 or L2 regularization, and early stopping.如果不能,下一个要添加的好东西是正则化,例如数据增强、 dropout 、L1 或 L2 正则化和提前停止。 The last one is especially useful if your validation performance starts decreasing at some point, instead of just plateauing.如果您的验证性能在某个时候开始下降,而不仅仅是稳定下来,那么最后一个特别有用。 It's not your case, so it should not be your first track.这不是你的情况,所以它不应该是你的第一首曲目。

If regularization is not enough, then try to play with the learning rate, or the other parameters mentioned in the book.如果正则化还不够,那么尝试使用学习率或书中提到的其他参数。 You should be able to make ResNet50 itself work much better than this on Cifar10 , but maybe it's not that trivial.应该能够使 ResNet50 本身在 Cifar10 上比这更好地工作,但也许这不是那么简单。

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

相关问题 良好的训练/验证准确度,但测试准确度差 - Good training/validation accuracy but poor test accuracy 良好的训练准确度和验证准确度,但预测准确度较差 - Good training accuracy and validaiton accuracy but poor prediction accuracy 良好的训练准确度和损失与验证的糟糕准确度 - Good accuracy and loss on training vs bad accuracy on validation 训练精度低于验证精度 - Training accuracy is less than validation accuracy 验证准确率非常低,但训练准确率很高 - Very low validation accuracy but high training accuracy 我已经为 10 个课程训练了一个 CNN 模型。 模型在训练准确度上表现不错,但在验证准确度上停滞不前 - I have trained a CNN model, for 10 classes. Model is doing good on training accuracy but is stuck in validation accuracy 验证准确性低且训练准确度高-keras imagedatagenerator flow_from_directory类别分类 - Low validation accuracy with good training accuracy - keras imagedatagenerator flow_from_directory categorical classification 绘制训练和验证的准确性和损失 - Plot training and validation accuracy and loss lstm中的训练和验证损失和准确性 - Training and validation loss and accuracy in lstm fastai - plot 验证和训练准确度 - fastai - plot validation and training accuracy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM