Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use loss or accuracy as the early stopping metric?

I am learning and experimenting with neural networks and would like to have the opinion from someone more experienced on the following issue:

When I train an Autoencoder in Keras ('mean_squared_error' loss function and SGD optimizer), the validation loss is gradually going down. and the validation accuracy is going up. So far so good.

However, after a while, the loss keeps decreasing but the accuracy suddenly falls back to a much lower low level.

  • Is it 'normal' or expected behavior that the accuracy goes up very fast and stay high to fall suddenly back?
  • Should I stop training at the maximum accuracy even if the validation loss is still decreasing? In other words, use val_acc or val_loss as metric to monitor for early stopping?

See images:

Loss: (green = val, blue = train] enter image description here

Accuracy: (green = val, blue = train] enter image description here

UPDATE: The comments below pointed me in the right direction and I think I understand it better now. It would be nice if someone could confirm that following is correct:

  • the accuracy metric measures the % of y_pred==Y_true and thus only make sense for classification.

  • my data is a combination of real and binary features. The reason why the accuracy graph goes up very steep and then falls back, while the loss continues to decrease is because around epoch 5000, the network probably predicted +/- 50% of the binary features correctly. When training continues, around epoch 12000, the prediction of real and binary features together improved, hence the decreasing loss, but the prediction of the binary features alone, are a little less correct. Therefor the accuracy falls down, while the loss decreases.

like image 766
Mark Avatar asked May 10 '16 14:05

Mark


People also ask

What criteria would you use for early stopping?

There are three elements to using early stopping; they are: Monitoring model performance. Trigger to stop training. The choice of model to use.

What is the metric for early stopping?

EarlyStopping class With this, the metric to be monitored would be 'loss' , and mode would be 'min' . A model. fit() training loop will check at end of every epoch whether the loss is no longer decreasing, considering the min_delta and patience if applicable. Once it's found no longer decreasing, model.

What is more important loss or accuracy?

People usually consider and care about the accuracy metric while model training. However, loss is something to be equally taken care of. By definition, Accuracy score is the number of correct predictions obtained. Loss values are the values indicating the difference from the desired target state(s).

How does early stopping avoid overfitting?

In machine learning, early stopping is a form of regularization used to avoid overfitting when training a learner with an iterative method, such as gradient descent. Such methods update the learner so as to make it better fit the training data with each iteration.


1 Answers

If the prediction is real-time or the data is continuous rather than discrete, then use MSE(Mean Square Error) because the values are real time.

But in the case of Discrete values (i.e) classification or clustering use accuracy because the values given are either 0 or 1 only. So, here the concept of MSE will not applicable, rather use accuracy= no of error values/total values * 100.

like image 107
Naren Babu R Avatar answered Sep 19 '22 07:09

Naren Babu R