kaira.losses.text.CrossEntropyLoss

Inheritance diagram for CrossEntropyLoss
- class kaira.losses.text.CrossEntropyLoss(weight=None, ignore_index=-100, label_smoothing=0.0)[source]
Bases:
BaseLossCross Entropy Loss Module.
This module calculates the cross entropy loss for classification tasks.
Methods
Initialize the CrossEntropyLoss module.
Forward pass through the CrossEntropyLoss module.
- __init__(weight=None, ignore_index=-100, label_smoothing=0.0)[source]
Initialize the CrossEntropyLoss module.
- Parameters:
weight (torch.Tensor, optional) – Class weights. Default is None.
ignore_index (int) – Index to ignore. Default is -100.
label_smoothing (float) – Label smoothing value. Default is 0.0.
- forward(x: Tensor, target: Tensor) Tensor[source]
Forward pass through the CrossEntropyLoss module.
- Parameters:
x (torch.Tensor) – The input logits tensor.
target (torch.Tensor) – The target tensor.
- Returns:
The cross entropy loss.
- Return type: