kaira.losses.text.LabelSmoothingLoss

Inheritance diagram for LabelSmoothingLoss
- class kaira.losses.text.LabelSmoothingLoss(smoothing=0.1, classes=0, dim=-1)[source]
Bases:
BaseLossLabel Smoothing Loss Module.
This module implements label smoothing to prevent overconfidence.
Methods
Initialize the LabelSmoothingLoss module.
Forward pass through the LabelSmoothingLoss module.
- forward(x: Tensor, target: Tensor) Tensor[source]
Forward pass through the LabelSmoothingLoss module.
- Parameters:
x (torch.Tensor) – The input logits tensor.
target (torch.Tensor) – The target tensor.
- Returns:
The label smoothing loss.
- Return type: