I don't have very clear the meaning of the parameter metrics of the compile method of the class model in Keras:

model.compile(..., metrics = ['accuracy'], ...)

the documentation states:

List of metrics to be evaluated by the model during training and testing

what I don't understand is:

are these the metrics used to evaluate the performance of the network at the end of each training epoch, i.e. at the end of each epoch the code makes the network predict on the training set and calculates the metrics passed


are these the metrics used to train the network, i.e. is the network trained with the goal of obtaining the best possible value for these metrics (I don't know how it could do this, something like: if the recall is low then it corrects the weights more when working with positive samples)?

(or it has another meaning?)


1 Answer 1


The argument metrics is meant to define your criterion for training evaluation. Let me make an example: if you are training a classifier, you want to evaluate your model based on how accurate (in percentage) it is. Therefore, your metric is accuracy (experessed as a float in the [0, 1] range). The higher the accuracy, the lower the loss, the better the model.

metrics must not be confused with loss. The loss function is something you need in order to "punish" your model when it makes mistakes. The loss function is at the basics of backpropagation and of weight update, it's the loss object what Neural Networks use to learn. Metrics instead is something that humans watch to understand how good a model is and communicate it.

The definition of some metrics is optional, you can evaluate a model based on the loss value only if you want. Sometimes you don't need to specify it. For example in regression tasks, i.e. when you have to predict continuous outputs, you speecify a loss (usually MSE or RMSE) and also evaluate your model based on that.

  • 1
    $\begingroup$ so what happens is that at the end of each epoch the metrics passed are used to evaluate the performance of the model making it predict on the training set? $\endgroup$
    – Ingen 77
    Commented Oct 1, 2019 at 15:32
  • 1
    $\begingroup$ Yes exactly. The metrics is telling us how good the model is doing throughout training, and how's its overall performance. It's not used by the model to tune its parameters (that's the loss function), but it's just something that us humans find useful to understand its goodness. $\endgroup$
    – Leevo
    Commented Oct 1, 2019 at 17:03
  • 2
    $\begingroup$ It also specifies what metrics are computed on the validation set at each epoch, if supplied, in addition to the training data. $\endgroup$
    – Sean Owen
    Commented Oct 1, 2019 at 19:02

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.