Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Loss, accuracy, validation loss, Validation accuracy?

At the end of each epoch, I am getting for example the following output:

Epoch 1/25
2018-08-06 14:54:12.555511: 
2/2 [==============================] - 86s 43s/step - loss: 6.0767 - acc: 0.0469 - val_loss: 4.1037 - val_acc: 0.2000
Epoch 2/25
2/2 [==============================] - 26s 13s/step - loss: 3.6901 - acc: 0.0938 - val_loss: 2.5610 - val_acc: 0.0000e+00
Epoch 3/25
2/2 [==============================] - 66s 33s/step - loss: 3.1491 - acc: 0.1406 - val_loss: 2.4793 - val_acc: 0.0500
Epoch 4/25
2/2 [==============================] - 44s 22s/step - loss: 3.0686 - acc: 0.0694 - val_loss: 2.3159 - val_acc: 0.0500
Epoch 5/25
2/2 [==============================] - 62s 31s/step - loss: 2.5884 - acc: 0.1094 - val_loss: 2.4601 - val_acc: 0.1500
Epoch 6/25
2/2 [==============================] - 41s 20s/step - loss: 2.7708 - acc: 0.1493 - val_loss: 2.2542 - val_acc: 0.4000
.
.
.
.

Can anyone explain me what's the difference between loss, accuracy, validation loss and validation accuracy?

like image 276
Rochan Avatar asked Aug 06 '18 09:08

Rochan


People also ask

What is the difference between validation Loss and Validation accuracy?

Only the loss function is used to update your model's parameters, the accuracy is only used for you to see how well your model is doing.

What is the difference between loss and validation loss?

The training loss indicates how well the model is fitting the training data, while the validation loss indicates how well the model fits new data.

What is the difference between loss and accuracy?

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).

What is accuracy and validation accuracy?

In other words, the test (or testing) accuracy often refers to the validation accuracy, that is, the accuracy you calculate on the data set you do not use for training, but you use (during the training process) for validating (or "testing") the generalisation ability of your model or for "early stopping".


3 Answers

When we mention validation_split as fit parameter while fitting DL model, it splits data into two parts for every epoch i.e. training data and validation data. It trains the model on training data and validate the model on validation data by checking its loss and accuracy.

Usually with every epoch increasing, loss goes lower and accuracy goes higher. But with val_loss and val_acc, many cases can be possible:

  1. val_loss starts increasing, val_acc starts decreasing(means model is cramming values not learning)

  2. val_loss starts increasing, val_acc also increases.(could be case of overfitting or diverse probability values in cases softmax is used in output layer)

  3. val_loss starts decreasing, val_acc starts increasing(Correct, means model build is learning and working fine)

This is a link to refer as well in which there is more description given. Thanks. How to interpret "loss" and "accuracy" for a machine learning model

I have tried to explain at https://www.javacodemonk.com/difference-between-loss-accuracy-validation-loss-validation-accuracy-when-training-deep-learning-model-with-keras-ff358faa

like image 125
Upasana Mittal Avatar answered Oct 12 '22 14:10

Upasana Mittal


In your model.compile function you have defined a loss function and a metrics function.

Your "loss" is the value of your loss function (unknown as you do not show your code) Your "acc" is the value of your metrics (in this case accuracy) The val_* simply means that the value corresponds to your validation data.

Only the loss function is used to update your model's parameters, the accuracy is only used for you to see how well your model is doing.

You should seek to minimize your loss and maximize your accuracy. Ideally the difference between your validation data results and your training data results should be similar (allthough some difference are expected)

like image 42
VegardKT Avatar answered Oct 12 '22 15:10

VegardKT


I think here is another answer that worth notifying:

val_loss is the value of cost function for your cross-validation data and loss is the value of cost function for your training data

https://datascience.stackexchange.com/a/25269

like image 31
sivi Avatar answered Oct 12 '22 14:10

sivi