It is not yet clear for me what metrics are (as given in the code below). What exactly are they evaluating? Why do we need to define them in the model
Reference: Keras Metrics Documentation
As given in the documentation page of keras metrics, a metric judges the performance of your model. The metrics argument in the compile method holds the list of metrics that needs to be evaluated by the model during its training and testing phases.
Metrics like:
binary_accuracy
categorical_accuracy
sparse_categorical_accuracy
top_k_categorical_accuracy and
sparse_top_k_categorical_accuracy
are the available metric functions that are supplied in the metrics parameter when the model is compiled.
Metric functions are customizable as well. When multiple metrics need to be evaluated it is passed in the form of a dictionary or a list.
One important resource you should refer for diving deep into metrics can be found here