tf.keras.losses.categorical_generalized_cross_entropy

Computes the Generalized Cross Entropy loss.

Generalized Cross Entropy (GCE) is a noise-robust loss function that provides better robustness against noisy labels than standard cross entropy. It generalizes both cross entropy and mean absolute error through the parameter q, where values closer to 1 make the loss more robust to noisy labels.

Formula:

loss = (1 - p**q) / q

where p is the predicted probability for the true class and q is the noise parameter.

y_true Ground truth labels. Expected to contain integer class indices with shape [batch_size] or [batch_size, 1].
y_pred The predicted class probabilities, with shape [batch_size, num_classes].
q Float in range (0, 1). It is the noise parameter. Controls the behavior of the loss:

  • As q approaches 0: Behaves more like cross entropy
  • As q approaches 1: Behaves more like mean absolute error

GCE loss values with shape [batch_size].


<!-- Tabular view -->
 <table class="responsive fixed orange">
<colgroup><col width="214px"><col></colgroup>
<tr><th colspan="2"><h2 class="add-link">References</h2></th></tr>
<tr class="alt">
<td colspan="2">
- [Zhang, Sabuncu, 2018](https://arxiv.org/abs/1805.07836)
("Generalized Cross Entropy Loss for Training
  Deep Neural Networks with Noisy Labels")
</td>
</tr>

</table>