What are all the valid strings I can use with keras.model.compile?
Question:
What strings are valid metrics with keras.model.compile
?
The following works,
model.compile(optimizer='sgd', loss='mse', metrics=['acc'])
but this does not work,
model.compile(optimizer='sgd', loss='mse', metrics=['recall', 'precision'])
Answers:
See keras source code, the list of metrics is
- accuracy
- binary_accuracy
- categorical_accuracy
- sparse_categorical_accuracy
- top_k_categorical_accuracy
- sparse_top_k_categorical_accuracy
- cosine_similarity
- binary_crossentropy
- categorical_crossentropy
- categorical_hinge
- hinge
- squared_hinge
- kullback_leibler_divergence
- logcosh
- mean_absolute_error
- mean_absolute_percentage_error
- mean_squared_error
- mean_squared_logarithmic_error
- poisson
- sparse_categorical_crossentropy
Possible abbreviations:
- acc = ACC = accuracy
- bce = BCE = binary_crossentropy
- mse = MSE = mean_squared_error
- mae = MAE = mean_absolute_error
- mape = MAPE = mean_absolute_percentage_error
- msle = MSLE = mean_squared_logarithmic_error
- log_cosh = logcosh
- cosine_proximity = cosine_similarity
any others will need to be added as custom objects, see this link
What strings are valid metrics with keras.model.compile
?
The following works,
model.compile(optimizer='sgd', loss='mse', metrics=['acc'])
but this does not work,
model.compile(optimizer='sgd', loss='mse', metrics=['recall', 'precision'])
See keras source code, the list of metrics is
- accuracy
- binary_accuracy
- categorical_accuracy
- sparse_categorical_accuracy
- top_k_categorical_accuracy
- sparse_top_k_categorical_accuracy
- cosine_similarity
- binary_crossentropy
- categorical_crossentropy
- categorical_hinge
- hinge
- squared_hinge
- kullback_leibler_divergence
- logcosh
- mean_absolute_error
- mean_absolute_percentage_error
- mean_squared_error
- mean_squared_logarithmic_error
- poisson
- sparse_categorical_crossentropy
Possible abbreviations:
- acc = ACC = accuracy
- bce = BCE = binary_crossentropy
- mse = MSE = mean_squared_error
- mae = MAE = mean_absolute_error
- mape = MAPE = mean_absolute_percentage_error
- msle = MSLE = mean_squared_logarithmic_error
- log_cosh = logcosh
- cosine_proximity = cosine_similarity
any others will need to be added as custom objects, see this link