1

我的机器学习模型极大地过度拟合了训练数据,但在测试数据上仍然表现良好。当使用神经网络方法时,每次迭代都会略微提高测试集的准确度,但会更多地提高训练集的准确度(过拟合)。

当使用带有 CNN 架构的 spacy 时,这个问题得到了很好的证明,我得到了以下结果

ITER    LOSS      P       R       F      TF  
 0      29.305  0.733   0.342   0.466   0.525
 1      10.410  0.811   0.443   0.573   0.650
 2      4.361   0.722   0.548   0.623   0.757
 3      2.265   0.764   0.563   0.648   0.811
 4      1.449   0.748   0.613   0.674   0.877

TF 是训练数据的 f1 分数。

测试分数不断提高,而与训练集的差异仅增加到在第 20 次迭代中模型在训练数据上几乎完美执行的点,而测试准确度从未降低以证明提前停止是合理的。

我尝试了许多正则化选项,包括不同的 dropout、权重衰减、L2,但似乎没有一个可以避免记住部分训练数据,并且在测试集上的表现都更差。

这个问题并不是 spacy 和我所遵循的方法所独有的,它也发生在 scikit 和参数较少的模型上。

手头的数据集是一个少于 2000 个示例的小数据集,是一个多标签文本分类任务。一些标签的示例少于 100 个,但在检查发生过度拟合的位置时,所有标签似乎都受到同样的影响。

我想我的主要问题是我是否应该担心模型正在记忆训练数据集,只要它在测试数据上表现良好,以及是否还有其他我没有考虑过的事情来解决这个记忆问题我看到了。

4

1 回答 1

1

To clarify, your loss function is always calculated on Training set, and thus overfitting may happen on the training set. To observe if there is overfitting, kindly use a DEV set (Which shouldn't be part of training set.). At the end of every epoch, calculate the loss on training-set and dev-set separately. Reducing loss function on dev-set shows well fitting of the model. While, increasing loss reveals overfitting. (You can use early stopping at this point, with some patience. But can always use a checkpoint to save the weights of performing their best). And the number epochs required to converge depends on the Learning rate, so a very lower learning rate may require lots of epoch for the model to fit.

于 2019-11-08T08:31:32.423 回答