0
$\begingroup$

I've read on one site that "if val_loss starts increasing and val_acc also increases, it could be a sign of overfitting". I thought these model results fit well, however, does the results below, in and of itself; lead you to view this as overfitting?

model= classification_model()
#fit model
model.fit(X_train, y_train, validation_data= (X_test, y_test), epochs = 10, verbose = 2)
#eval model
results = model.evaluate(X_test, y_test, verbose =0)

Train on 60000 samples, validate on 10000 samples
Epoch 1/10
 - 113s - loss: 0.1839 - accuracy: 0.9449 - val_loss: 0.0984 - val_accuracy: 0.9679
Epoch 2/10
 - 104s - loss: 0.0774 - accuracy: 0.9759 - val_loss: 0.0834 - val_accuracy: 0.9742
Epoch 3/10
 - 160s - loss: 0.0526 - accuracy: 0.9834 - val_loss: 0.0869 - val_accuracy: 0.9752
Epoch 4/10
 - 133s - loss: 0.0395 - accuracy: 0.9875 - val_loss: 0.0705 - val_accuracy: 0.9789
Epoch 5/10
 - 103s - loss: 0.0285 - accuracy: 0.9913 - val_loss: 0.0808 - val_accuracy: 0.9775
Epoch 6/10
 - 99s - loss: 0.0258 - accuracy: 0.9917 - val_loss: 0.0733 - val_accuracy: 0.9804
Epoch 7/10
 - 113s - loss: 0.0222 - accuracy: 0.9927 - val_loss: 0.0934 - val_accuracy: 0.9779
Epoch 8/10
 - 111s - loss: 0.0213 - accuracy: 0.9928 - val_loss: 0.0909 - val_accuracy: 0.9792
Epoch 9/10
 - 108s - loss: 0.0165 - accuracy: 0.9945 - val_loss: 0.1161 - val_accuracy: 0.9771
Epoch 10/10
 - 143s - loss: 0.0171 - accuracy: 0.9948 - val_loss: 0.1040 - val_accuracy: 0.9752
$\endgroup$
4
  • $\begingroup$ your training loss/accuracy keep improving while your validation loss/accuracy start getting worse, which is effectively your model telling you that it's overfitting. It's basically doing all it can to fit the training data, and is starting to take advantage of the slightest accidental correlations and incidental patterns it can find within this data — correlations and patterns which don't exist in the validation data. $\endgroup$ – Jivan Sep 29 '20 at 20:16
  • 2
    $\begingroup$ as a general rule, overfitting is due to a misbalance between the complexity of your model and the volume of your data. Too complex a model with not enough data will usually lead to overfitting. In theory, if your model's complexity is aligned with the complexity and volume of your data, then after enough iterations it will stop improving but will not overfit dramatically. As a consequence, to reduce overfitting, you might either get more data (and more diverse), or make your model simpler. $\endgroup$ – Jivan Sep 29 '20 at 20:20
  • $\begingroup$ Ok thanks for this. I am going to tweak it a bit. $\endgroup$ – Foreverlearning Sep 30 '20 at 0:27
  • $\begingroup$ As Jivan said, the trade-off is not between loss and accuracy (they are two sides of the same coin) but between training and validation. See this and it will help datascience.stackexchange.com/a/9760/8878 $\endgroup$ – Kasra Manshaei Sep 30 '20 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.