# tf.contrib.sparsemax.sparsemax_loss

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/sparsemax/python/ops/sparsemax_loss.py#L28-L76) |

Computes sparsemax loss function [1](https://arxiv.org/abs/1602.02068).

    tf.contrib.sparsemax.sparsemax_loss(
        logits, sparsemax, labels, name=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `logits` | A `Tensor`. Must be one of the following types: `half`, `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). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor`. Has the same type as `logits`. ||

<br />