LabelSmoothing (original) (raw)

Back to top

Edit this page

Toggle table of contents sidebar

class composer.algorithms.LabelSmoothing(smoothing=0.1, target_key=1)[source]#

Shrink targets towards a uniform distribution as in Szegedy et al.

The smoothed labels are computed as (1 - smoothing) * targets + smoothing * unifwhere unif is a vector with elements all equal to 1 / num_classes.

Parameters

Example

from composer.algorithms import LabelSmoothing algorithm = LabelSmoothing(smoothing=0.1) trainer = Trainer( model=model, train_dataloader=train_dataloader, eval_dataloader=eval_dataloader, max_duration="1ep", algorithms=[algorithm], optimizers=[optimizer] )