简体   繁体   English

我的神经网络是过拟合还是欠拟合?

[英]Is my neural network suffering from overfitting or underfitting?

I am trying to construct a multi-class neural network that predicts rock paper or scissors as accurately as possible from a data set I created.我正在尝试构建一个多类神经网络,从我创建的数据集中尽可能准确地预测石头或剪刀。

As I messed around with various parameters, the training set's loss/accuracy seems to vary widely.当我处理各种参数时,训练集的损失/准确性似乎差异很大。 However, after a lot of trial and error, this seems to be the best model version.然而,经过大量的试验和错误,这似乎是最好的 model 版本。 I have looked over other questions relating to mine and I think these graphs seems appropriate, but being as I am a new to machine learning, I am wondering the model is suffering from some issue (over fitting/under fitting) that I am just not seeing.我查看了与我有关的其他问题,我认为这些图表似乎很合适,但由于我是机器学习的新手,我想知道 model 遇到了一些问题(过拟合/欠拟合),我只是没有看到。

I understand overfitting refers to the case where as epochs increase, accuracy goes up and the loss goes down, but I am still unsure if there is something obvious on the graph that is escaping my understanding.我理解过度拟合是指随着时代的增加,准确度上升而损失下降的情况,但我仍然不确定图表上是否有明显的东西是 escaping 我的理解。

This is how I'm currently compiling and fitting the model.这就是我目前正在编译和安装 model 的方式。

model.compile(loss=['categorical_crossentropy'], optimizer=Adam(.01), metrics=['accuracy'])

history = model.fit(X_train,y_train, epochs=30, verbose=True, validation_split=.33, batch_size=3)

Model Accuracy Model 精度

Model Loss Model 损失

Edit:编辑:

The model should predict either rock paper or scissors based upon previously decided coefficients being multiplied against 9 features. model 应该根据先前确定的系数与 9 个特征相乘来预测石头纸或剪刀。 5 features being randomly created coefficients representing the Big 5 Personality Dimensions ranging as continuous values from -2 to 2. 5 个特征是随机创建的系数,代表 5 大人格维度的连续值,范围从 -2 到 2。

The other four are:其他四个是:

  1. If they won or lost.如果他们赢了或输了。

2, 3, 4) If they won choosing rock, paper, or scissors: and each of those three being multiplied against a coefficient that acts as the bias toward them winning. 2, 3, 4) 如果他们赢了,选择石头、纸或剪刀:这三者中的每一个都与一个系数相乘,该系数作为他们获胜的偏差。

The probability of choosing rock paper or scissors have an activation built in that gives a bias toward the respective choice.选择石头或剪刀的概率有一个内置的激活,它会偏向各自的选择。 Scissors has the highest bias. Scissors 的偏差最大。

There are 999 trials (excluded the first since its due to random chance) and each of the 100 trial values, for the Big 5 Personality dimension, remain the same.有 999 次试验(由于随机机会而排除了第一次试验),并且 100 次试验值中的每一个,对于 Big 5 Personality 维度,都保持不变。 Only the columns representing Won/Lost and won choosing rock, paper, or scissors change trial by trial.只有代表赢/输和赢选择石头、纸或剪刀的列会逐次更改。

From the loss and accuracy curve, it does seem like you've fitted your model to the training data very precisely (a sign of overfitting).从损失和准确度曲线来看,您似乎已经非常精确地将 model 拟合到训练数据(过度拟合的迹象)。 If you're worried about the overfitting issue then you may adopt some regularization methods like L1/L2 regularizer (weight decay), Dropout, Batch Norm, etc. They will help the model generalize well to the unseen data.如果您担心过拟合问题,那么您可以采用一些正则化方法,例如 L1/L2 正则化器(权重衰减)、Dropout、Batch Norm 等。它们将帮助 model 很好地泛化到看不见的数据。 Also, methods like "early stopping" are also applicable in such a scenario.此外,类似“提前停止”的方法也适用于这种场景。 Hope it'll help you mitigate your issue of overfitting.希望它能帮助您减轻过度拟合的问题。

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

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