5
$\begingroup$

In the keras documentation an example for the usage of metrics is given when compiling the model:

model.compile(loss='mean_squared_error',
              optimizer='sgd',
              metrics=['mae', 'acc'])

Here, both the mean_absolute_error and accuracy are selected. It is not explained, however, why and when specifying two or more metrics might be useful. What is happening in the training phase in such case? Are all of the chosen metrics used somehow? When might I want to consider choosing more than one metric? In particular, I am training a deep neural net, is there a specific metric I should be looking at?

Edit: thanks to the answer of @Alexey Burnakov I realized that the metrics do not take part in the training, so I update my question.

$\endgroup$

2 Answers 2

9
$\begingroup$

loss='mean_squared_error'

We divide these terms into differentiable loss function that's used to train neural network weights, and quality metrics that are used to assess the quality of the training convergence.

In your example, $$L = (Y - Y') ^ 2 / n$$ is the loss function which is minimzed along the training phase.

The metrics will be shown in log and on plot to give you an indication of how good your model performs at this stage of the training phase. They are not used as optimization functions.

$\endgroup$
2
  • 2
    $\begingroup$ Oh, I see! So this is just a selection of what you would like to plot as a measure of the training. They do not affect the training phase? $\endgroup$ Oct 31, 2019 at 14:27
  • 4
    $\begingroup$ Absolutely right. What matters to training is the loss. You can, however, use the metrics to early stop the training (Keras allows this). $\endgroup$ Oct 31, 2019 at 14:28
0
$\begingroup$

For classification problems, sometimes cross-entropy is preferable for the "objective function" (metric), as compared with the MSE (mean square error). MSE is absolutely required if you use ANNs for function approximation problems (vs. classification problems). Would recommend looking at texts (books) like Bishop or Ripley instead of reading software manuals.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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