composer.algorithms.functional.smooth_labels

composer.algorithms.functional.smooth_labels(logits, targets, alpha)[source]

Shrinks targets towards a prior distribution to counteract label noise.

This is computed by (1 - alpha) * targets + alpha * smoothed_targets where smoothed_targets is a pre-specified vector of class probabilities.

Introduced in: https://arxiv.org/abs/1512.00567 Evaluated in: https://arxiv.org/abs/1906.02629

Parameters
  • logits (torch.Tensor) – Output of the model. Tensor of shape (N, C, d1, …, dn) for N examples and C classes, and d1, …, dn extra dimensions.

  • targets (torch.Tensor) – Tensor of shape (N) containing integers 0 <= i <= C-1 specifying the target labels for each example.

  • alpha (float) – Strength of the label smoothing, between [0, 1]. alpha=0 means no label smoothing, and alpha=1 means maximal smoothing (targets are ignored)