# Module: tf.keras.losses

<br />

#### View aliases


**Main aliases**

[`tf.losses`](https://www.tensorflow.org/api_docs/python/tf/keras/losses)

<br />

## Classes

[`class BinaryCrossentropy`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/BinaryCrossentropy): Computes the cross-entropy loss between true labels and predicted labels.

[`class BinaryFocalCrossentropy`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/BinaryFocalCrossentropy): Computes focal cross-entropy loss between true labels and predictions.

[`class CategoricalCrossentropy`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/CategoricalCrossentropy): Computes the crossentropy loss between the labels and predictions.

[`class CategoricalFocalCrossentropy`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/CategoricalFocalCrossentropy): Computes the alpha balanced focal crossentropy loss.

[`class CategoricalHinge`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/CategoricalHinge): Computes the categorical hinge loss between `y_true` \& `y_pred`.

[`class CosineSimilarity`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/CosineSimilarity): Computes the cosine similarity between labels and predictions.

[`class Hinge`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/Hinge): Computes the hinge loss between `y_true` \& `y_pred`.

[`class Huber`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/Huber): Computes the Huber loss between `y_true` \& `y_pred`.

[`class KLDivergence`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/KLDivergence): Computes Kullback-Leibler divergence loss between `y_true` \& `y_pred`.

[`class LogCosh`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/LogCosh): Computes the logarithm of the hyperbolic cosine of the prediction error.

[`class Loss`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/Loss): Loss base class.

[`class MeanAbsoluteError`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/MeanAbsoluteError): Computes the mean of absolute difference between labels and predictions.

[`class MeanAbsolutePercentageError`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/MeanAbsolutePercentageError): Computes the mean absolute percentage error between `y_true` \& `y_pred`.

[`class MeanSquaredError`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/MeanSquaredError): Computes the mean of squares of errors between labels and predictions.

[`class MeanSquaredLogarithmicError`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/MeanSquaredLogarithmicError): Computes the mean squared logarithmic error between `y_true` \& `y_pred`.

[`class Poisson`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/Poisson): Computes the Poisson loss between `y_true` \& `y_pred`.

[`class Reduction`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/Reduction): Types of loss reduction.

[`class SparseCategoricalCrossentropy`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/SparseCategoricalCrossentropy): Computes the crossentropy loss between the labels and predictions.

[`class SquaredHinge`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/SquaredHinge): Computes the squared hinge loss between `y_true` \& `y_pred`.

## Functions

[`KLD(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/kl_divergence): Computes Kullback-Leibler divergence loss between `y_true` \& `y_pred`.

[`MAE(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_absolute_error): Computes the mean absolute error between labels and predictions.

[`MAPE(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_absolute_percentage_error): Computes the mean absolute percentage error between `y_true` \& `y_pred`.

[`MSE(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_squared_error): Computes the mean squared error between labels and predictions.

[`MSLE(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_squared_logarithmic_error): Computes the mean squared logarithmic error between `y_true` \& `y_pred`.

[`binary_crossentropy(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/binary_crossentropy): Computes the binary crossentropy loss.

[`binary_focal_crossentropy(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/binary_focal_crossentropy): Computes the binary focal crossentropy loss.

[`categorical_crossentropy(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/categorical_crossentropy): Computes the categorical crossentropy loss.

[`categorical_focal_crossentropy(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/categorical_focal_crossentropy): Computes the categorical focal crossentropy loss.

[`categorical_hinge(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/categorical_hinge): Computes the categorical hinge loss between `y_true` \& `y_pred`.

[`cosine_similarity(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/cosine_similarity): Computes the cosine similarity between labels and predictions.

[`deserialize(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/deserialize): Deserializes a serialized loss class/function instance.

[`get(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/get): Retrieves a Keras loss as a `function`/`Loss` class instance.

[`hinge(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/hinge): Computes the hinge loss between `y_true` \& `y_pred`.

[`huber(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/huber): Computes Huber loss value.

[`kl_divergence(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/kl_divergence): Computes Kullback-Leibler divergence loss between `y_true` \& `y_pred`.

[`kld(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/kl_divergence): Computes Kullback-Leibler divergence loss between `y_true` \& `y_pred`.

[`kullback_leibler_divergence(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/kl_divergence): Computes Kullback-Leibler divergence loss between `y_true` \& `y_pred`.

[`log_cosh(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/log_cosh): Logarithm of the hyperbolic cosine of the prediction error.

[`logcosh(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/log_cosh): Logarithm of the hyperbolic cosine of the prediction error.

[`mae(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_absolute_error): Computes the mean absolute error between labels and predictions.

[`mape(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_absolute_percentage_error): Computes the mean absolute percentage error between `y_true` \& `y_pred`.

[`mean_absolute_error(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_absolute_error): Computes the mean absolute error between labels and predictions.

[`mean_absolute_percentage_error(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_absolute_percentage_error): Computes the mean absolute percentage error between `y_true` \& `y_pred`.

[`mean_squared_error(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_squared_error): Computes the mean squared error between labels and predictions.

[`mean_squared_logarithmic_error(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_squared_logarithmic_error): Computes the mean squared logarithmic error between `y_true` \& `y_pred`.

[`mse(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_squared_error): Computes the mean squared error between labels and predictions.

[`msle(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/mean_squared_logarithmic_error): Computes the mean squared logarithmic error between `y_true` \& `y_pred`.

[`poisson(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/poisson): Computes the Poisson loss between y_true and y_pred.

[`serialize(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/losses/serialize): Serializes loss function or `Loss` instance.

[`sparse_categorical_crossentropy(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/sparse_categorical_crossentropy): Computes the sparse categorical crossentropy loss.

[`squared_hinge(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/metrics/squared_hinge): Computes the squared hinge loss between `y_true` \& `y_pred`.