opennmt.utils.cross_entropy_loss

opennmt.utils.cross_entropy_loss(logits, labels, label_smoothing=0.0, training=None)[source]

Computes the cross entropy loss.

Parameters
  • logits – The unscaled probabilities.

  • labels – The true labels.

  • label_smoothing – The label smoothing value.

  • training – Compute training loss.

Returns

The cumulated loss and the loss normalizer.