7

I have written a model in Keras (with theano backend) and compile my model like this:

model.compile(Adam(0.001), loss='mse', metrics=['mse', 'mae'])

i.e. my objective loss function is mean squared error and the metrics to report are mean squared error and mean absolute error.

Then I run my model:

model.fit(X_train, y_train, nb_epoch=500, validation_data=(X_test, y_test))

Keras reports results as:

> Epoch 500/500:
0s - loss: 5.5990 - mean_squared_error: 4.4311 - mean_absolute_error: 0.9511 - val_loss: 7.5573 - val_mean_squared_error: 6.3877 - val_mean_absolute_error: 1.1335

I expected val_loss to be same as val_mean_squared_error. What is val_loss here if not val_mean_squared_error?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
kamalbanga
  • 1,881
  • 5
  • 27
  • 46
  • I would expect the same thing. That is some strange behavior. I am facing a similar problem (http://stackoverflow.com/questions/43938176/why-differ-metrics-calculated-by-model-evaluate-from-tracked-metrics-during-tr). It seems, there is some trouble at calculating metrics in Keras... – D.Laupheimer May 12 '17 at 12:51
  • 1
    Are you using any regularization layers? Their penalties add up to final loss. – Ayush Garg Feb 23 '18 at 20:51
  • could you share your network configuration as well? it will make things clearer – papayiannis Jul 23 '18 at 15:18
  • This seems to be the same issue (bug) as described here https://stackoverflow.com/questions/54802328/why-am-i-getting-different-values-between-loss-functions-and-metrics-in-tensorfl – pittnerf Dec 08 '21 at 05:59

0 Answers0