TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tfa.losses.sparsemax_loss

View source on GitHub

Sparsemax loss function 1.

tfa.losses.sparsemax_loss(
    logits,
    sparsemax,
    labels,
    name=None
)

Computes the generalized multi-label classification loss for the sparsemax function. The implementation is a reformulation of the original loss function such that it uses the sparsemax properbility output instead of the internal au variable. However, the output is identical to the original loss function.

Args:

  • logits: A Tensor. Must be one of the following types: float32, float64.
  • sparsemax: A Tensor. Must have the same type as logits.
  • labels: A Tensor. Must have the same type as logits.
  • name: A name for the operation (optional).

Returns:

A Tensor. Has the same type as logits.