问题描述
我正在尝试使用深度学习来预测来自约会网站的 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 .
我们已经尝试去除正则化和 dropout,正如预期的那样,它们以过度拟合告终(训练 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 训练准确度更高的验证准确度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!