I am currently training a neural network and I cannot decide which to use to implement my Early Stopping criteria: validation loss or a metrics like accuracy/f1score/auc/whatever calculated on the validation set.

In my research, I came upon articles defending both standpoints. Keras seems to default to the validation loss but I have also come across convincing answers for the opposite approach (e.g. here).

Anyone has directions on when to use preferably the validation loss and when to use a specific metric?


TLDR; Monitor the loss rather than the accuracy

I will answer my own question since I think that the answers received missed the point and someone might have the same problem one day.

First, let me quickly clarify that using early stopping is perfectly normal when training neural networks (see the relevant sections in Goodfellow et al's Deep Learning book, most DL papers, and the documentation for keras' EarlyStopping callback).

Now, regarding the quantity to monitor: prefer the loss to the accuracy. Why? The loss quantify how certain the model is about a prediction (basically having a value close to 1 in the right class and close to 0 in the other classes). The accuracy merely account for the number of correct predictions. Similarly, any metrics using hard predictions rather than probabilities have the same problem.

Obviously, whatever metrics you end up choosing, it has to be calculated on a validation set and not a training set (otherwise, you are completely missing the point of using EarlyStopping in the first place)

  • $\begingroup$ If values are between 0 and 1, cross_entropy loss is a more preferable candidate than MSE or MAE. Checkout the Wrap-Up section of this article, and this post on stats. $\endgroup$ – Esmailian Apr 19 '19 at 16:16
  • 1
    $\begingroup$ @Esmailian it is not a matter of preference; for classification problems, MSE & MAE are simply not appropriate. $\endgroup$ – desertnaut Sep 2 '19 at 17:22
  • $\begingroup$ @desertnaut Misha Belkin might disagree with you: arxiv.org/pdf/1812.11118.pdf I'd usually agree with your point but perhaps that unquestioned belief is unfounded. $\endgroup$ – Charlie Parker Mar 4 at 17:52
  • $\begingroup$ @qmeeus sorry if I am missing your point, but why is loss better than accuracy? We want to do well on the accuracy at "test time" so I'd personally track the accuracy not the loss. The loss is usually a made up quantity that upper bounds what we really want to do (convex surrogate functions). $\endgroup$ – Charlie Parker Mar 4 at 17:53
  • 1
    $\begingroup$ @CharlieParker, accuracy is rarely what you want (problem with class imbalance, etc.) but even ignoring this problem, a model that predicts each example correctly with a large confidence is preferable to a model that predicts each example correctly with a 51% confidence. The accuracy being a discrete transformation of the class probabilities, it does not allow you to make this distinction. Cross-entropy does. It does not impact the error rate on out of distribution samples but what does anyway? ;) $\endgroup$ – qmeeus Mar 5 at 9:16

In my opinion, this is subjective and problem specific. You should use whatever is the most important factor in your mind as the driving metric, as this might make your decisions on how to alter the model better focussed.

Most metrics one can compute will be correlated/similar in many ways: e.g. if you use MSE for your loss, then recording MAPE (mean average percentage error) or simple $L_1$ loss, they will give you comparable loss curves.

For example, if you will report an F1-score in your report/to your boss etc. (and assuming that is what they really care about), then using that metric could make most sense. The F1-score, for example, takes precision and recall into account i.e. it describes the relationship between two more fine-grained metrics.

Bringing those things together, computing scores other than normal loss may be nice for the overview and to see how your final metric is optimised over the course of the training iterations. That relationship could perhaps give you a deeper insight into the problem,

It is usually best to try several options, however, as optimising for the validation loss may allow training to run for longer, which eventually may also produce a superior F1-score. Precision and recall might sway around some local minima, producing an almost static F1-score - so you would stop training. If you had been optimising for pure loss, you might have recorded enough fluctuation in loss to allow you to train for longer.

  • $\begingroup$ Why would using validation loss allow for training longer than using a metrics? Also, can you elaborate on the difference between the two options? Do you see a case where it would be a bad idea to use a metric rather than the loss? $\endgroup$ – qmeeus Aug 20 '18 at 14:43
  • $\begingroup$ @id-2205 - please see my edited answer. $\endgroup$ – n1k31t4 Aug 20 '18 at 17:00
  • $\begingroup$ interesting point! I am currently using accuracy for early stopping but I will try to use the validation loss. I don't expect any changes in the training process though ! Thank you for your answer $\endgroup$ – qmeeus Aug 21 '18 at 19:30

I am currently training a neural network and I cannot decide which to use to implement my Early Stopping criteria: validation loss or a metrics like accuracy/f1score/auc/whatever calculated on the validation set.

If you are training a deep network, I highly recommend you not to use early stop. In deep learning, it is not very customary. Instead, you can employ other techniques like drop out for generalizing well. If you insist on that, choosing criterion depends on your task. If you have unbalanced data, you have to employ F1 score and evaluate it on your cross-validation data. If you have balanced data, try to use accuracy on your cross-validation data. Other techniques highly depend on your task.

I highly encourage you to find a model which fits your data very well and employ drop out after that. This is the most customary thing people use for deep models.

  • 3
    $\begingroup$ I am using dropout as well. However, I can't find a reason why early stopping should not be used though... $\endgroup$ – qmeeus Aug 21 '18 at 19:21
  • $\begingroup$ Early stop tries to solve both learning and generalization problems. On the other hand drop out just tries to overcome the generalization problem. $\endgroup$ – Media Aug 21 '18 at 19:35
  • 1
    $\begingroup$ You don't answer my question... I don't deny the fact that dropout is useful and should be used to protect against overfitting, I couldn't agree more on that. My question is: why do you say that early stop should not be used with ANN? (cf your first sentence: If you are training a deep network, I highly recommend you not to use early stop.) $\endgroup$ – qmeeus Aug 21 '18 at 20:22
  • $\begingroup$ Did you read my last comment? It exactly answers your question. It's a famous quote from pr. Ng in his deep learning class, second course. The latter case is an easier task due to not struggling to solve multple tasks simoltaneously. $\endgroup$ – Media Aug 21 '18 at 21:43
  • 3
    $\begingroup$ And in order to find it and find the right set of hyperparameters, I'm employing some kind of directed grid search with early stop for the reasons I explained above. Point taken though and once I have selected the final model and I will train it, I will not use early stop. Thank you for this interesting discussion and for you advice $\endgroup$ – qmeeus Aug 22 '18 at 11:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.