要传递给 model.compile() 的损失函数的缩写?

Abbreviations for loss functions to be passed to model.compile()?

Here describes different loss functions, but it is possible to use abbreviations instead of importing and passing the actual loss object (see an examples here)

MeanSquaredError 可以作为字符串 mse 传递,MeanAbsoluteError 作为 mae 传递。有些是显而易见的,但其他损失如 CategoricalCrossentropyCosineSimilarityHinge 又如何呢?

下面是一些损失函数和它们的字符串别名(都可以从tf.keras.losses导入):

Class Name String Alias(es)
MeanSquaredError() mean_squared_error, mse, MSE
MeanAbsoluteError() mean_absolute_error, mae, MAE
MeanAbsolutePercentageError() mean_absolute_percentage_error, mape, MAPE
MeanSquaredLogarithmicError() mean_squared_logarithmic_error, msle, MSLE
KLDivergence() kl_divergence, kullback_leibler_divergence, kld, KLD
Hinge() hinge
CosineSimilarity() cosine_similarity
LogCosh() log_cosh, logcosh
CategoricalCrossentropy() categorical_crossentropy
SparseCategoricalCrossentropy() sparse_categorical_crossentropy
BinaryCrossentropy() binary_crossentropy

如您所见,其中一些有不止一个字符串别名,而大多数只有一个别名。

参考:Source code of keras.losses