验证准确性高于使用Tensorflow和Keras训练准确性 [英] Higher validation accuracy, than training accurracy using Tensorflow and Keras

查看:93
本文介绍了验证准确性高于使用Tensorflow和Keras训练准确性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用深度学习从约会网站的15种自我报告的属性中预测收入.

I'm trying to use deep learning to predict income from 15 self reported attributes from a dating site.

我们得到的结果很奇怪,与我们的训练数据相比,我们的验证数据具有更高的准确性和更低的损失.这在不同大小的隐藏层之间是一致的. 这是我们的模型:

We're getting rather odd results, where our validation data is getting better accuracy and lower loss, than our training data. And this is consistent across different sizes of hidden layers. This is our model:

for hl1 in [250, 200, 150, 100, 75, 50, 25, 15, 10, 7]:
    def baseline_model():
        model = Sequential()
        model.add(Dense(hl1, input_dim=299, kernel_initializer='normal', activation='relu', kernel_regularizer=regularizers.l1_l2(0.001)))
        model.add(Dropout(0.5, seed=seed))
        model.add(Dense(3, kernel_initializer='normal', activation='sigmoid'))

        model.compile(loss='categorical_crossentropy', optimizer='adamax', metrics=['accuracy'])
        return model

    history_logs = LossHistory()
    model = baseline_model()
    history = model.fit(X, Y, validation_split=0.3, shuffle=False, epochs=50, batch_size=10, verbose=2, callbacks=[history_logs])

这是准确性和损失的一个示例: 和.

And this is an example of the accuracy and losses: and .

我们已尝试消除正则化和辍学现象,正如预期的那样,结果以过度拟合告终(培训acc:约85%).我们甚至尝试过大幅度降低学习率,取得相似的结果.

We've tried to remove regularization and dropout, which, as expected, ended in overfitting (training acc: ~85%). We've even tried to decrease the learning rate drastically, with similiar results.

有人看到过类似的结果吗?

Has anyone seen similar results?

推荐答案

由于使用培训和测试的行为不同,因此在使用Dropout时会发生这种情况.

This happens when you use Dropout, since the behaviour when training and testing are different.

在训练时,功能的百分比设置为零(在您的情况下为50%,因为您正在使用Dropout(0.5)).测试时,将使用所有功能(并适当缩放).因此,测试时的模型更加健壮-可以带来更高的测试准确性.

When training, a percentage of the features are set to zero (50% in your case since you are using Dropout(0.5)). When testing, all features are used (and are scaled appropriately). So the model at test time is more robust - and can lead to higher testing accuracies.

这篇关于验证准确性高于使用Tensorflow和Keras训练准确性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆