Since Sergii's answer, Keras library has been cleaned up quite a bit and the source code is pretty readable nowadays. The metrics are defined in tensorflow.keras.metrics
(whose documentation can be found here) and the losses are defined in tensorflow.keras.losses
(docs). There's a bit of overlap with the metrics module but that's expected given a particular loss function can also be tracked as a metric.
Also, if we inspect the source code, unless the metric is accuracy, get()
method is called on the metrics
module to get the particular metric function, i.e. tf.keras.metrics.get('binary_accuracy')
. On the other hand, the get()
method is always called to fetch the particular loss function.
Also, the type of accuracy is chosen depending on the the target type (binary_accuracy
, categorical_accuracy
etc.).
All metrics/losses can be printed calling dir()
on the modules.
metrics_list = [m for m in dir(tf.keras.metrics) if not m.startswith('_')]
losses_list = [m for m in dir(tf.keras.losses) if not m.startswith('_')]