Losses

Losses#

binary_dice_loss(predictions, targets, *[, ...])

Binary Dice Loss convenience function.

convex_kl_divergence(log_predictions, targets)

cosine_distance(predictions, targets, *[, ...])

Computes the cosine distance between targets and predictions.

cosine_similarity(predictions, targets, *[, ...])

Computes the cosine similarity between targets and predictions.

ctc_loss(logits, logit_paddings, labels, ...)

Computes CTC loss.

ctc_loss_with_forward_probs(logits, ...[, ...])

Computes CTC loss and CTC forward-probabilities.

dice_loss(predictions, targets, *[, ...])

Computes the Dice Loss for multi-class segmentation.

generalized_kl_divergence(log_predictions, ...)

Computes the generalized Kullback-Leibler divergence loss.

hinge_loss(predictor_outputs, targets)

Computes the hinge loss for binary classification.

huber_loss(predictions[, targets, delta])

Huber loss, similar to L2 loss close to zero, L1 loss away from zero.

kl_divergence(log_predictions, targets[, ...])

Computes the Kullback-Leibler divergence (relative entropy) loss.

kl_divergence_with_log_targets(...[, axis, ...])

Computes the Kullback-Leibler divergence (relative entropy) loss.

l2_loss(predictions[, targets])

Calculates the L2 loss for a set of predictions.

log_cosh(predictions[, targets])

Calculates the log-cosh loss for a set of predictions.

make_fenchel_young_loss(max_fun)

Creates a Fenchel-Young loss from a max function.

multiclass_generalized_dice_loss(...[, ...])

Computes Multiclass Generalized Dice Loss with automatic class weighting.

multiclass_hinge_loss(scores, labels)

Multiclass hinge loss.

multiclass_perceptron_loss(scores, labels)

Multiclass perceptron loss.

multiclass_sparsemax_loss(scores, labels)

Multiclass sparsemax loss.

ntxent(embeddings, labels[, temperature])

Normalized temperature scaled cross entropy loss (NT-Xent).

perceptron_loss(predictor_outputs, targets)

Binary perceptron loss.

poly_loss_cross_entropy(logits, labels, *[, ...])

Computes PolyLoss between logits and labels.

ranking_softmax_loss(logits, labels, *, ...)

Ranking softmax loss.

safe_softmax_cross_entropy(logits, labels)

Computes the softmax cross entropy between sets of logits and labels.

sigmoid_binary_cross_entropy(logits, labels)

Computes element-wise sigmoid cross entropy given logits and labels.

sigmoid_focal_loss(logits, labels, *[, ...])

Sigmoid focal loss with numerical stability improvements.

smooth_labels(labels, alpha, *[, axis, where])

Apply label smoothing.

softmax_cross_entropy(logits, labels[, ...])

Computes the softmax cross entropy between sets of logits and labels.

softmax_cross_entropy_with_integer_labels(...)

Computes softmax cross entropy between the logits and integer labels.

sparsemax_loss(logits, labels)

Binary sparsemax loss.

squared_error(predictions[, targets])

Calculates the squared error for a set of predictions.

triplet_margin_loss(anchors, positives, ...)

Returns the triplet loss for a batch of embeddings.