composer.algorithms.functional.smooth_labels
- composer.algorithms.functional.smooth_labels(logits: torch.Tensor, targets: torch.Tensor, alpha: float)[source]
Shrinks targets towards a uniform distribution to counteract label noise as in Szegedy et al..
This is computed by
(1 - alpha) * targets + alpha * smoothed_targets
wheresmoothed_targets
is a vector of ones.- Parameters
logits – Output of the model. Tensor of shape (N, C, d1, …, dn) for N examples and C classes, and d1, …, dn extra dimensions.
targets – Tensor of shape (N) containing integers 0 <= i <= C-1 specifying the target labels for each example.
alpha – Strength of the label smoothing, in [0, 1].
alpha=0
means no label smoothing, andalpha=1
means maximal smoothing (targets are ignored).