Criterion

Joint CTC-CrossEntropy Loss

class lightning_asr.criterion.joint_ctc_cross_entropy.JointCTCCrossEntropyLoss(num_classes: int, ignore_index: int, dim: int = - 1, reduction='mean', ctc_weight: float = 0.3, cross_entropy_weight: float = 0.7, blank_id: Optional[int] = None)[source]

Privides Joint CTC-CrossEntropy Loss function

Parameters
  • num_classes (int) – the number of classification

  • ignore_index (int) – indexes that are ignored when calculating loss

  • dim (int) – dimension of calculation loss

  • reduction (str) – reduction method [sum, mean] (default: mean)

  • ctc_weight (float) – weight of ctc loss

  • cross_entropy_weight (float) – weight of cross entropy loss

  • blank_id (int) – identification of blank for ctc

Label Smoothed CrossEntropy Loss

class lightning_asr.criterion.label_smoothed_cross_entropy.LabelSmoothedCrossEntropyLoss(num_classes: int, ignore_index: int, smoothing: float = 0.1, dim: int = - 1, reduction='mean')[source]

Label smoothed cross entropy loss function.

Parameters
  • num_classes (int) – the number of classfication

  • ignore_index (int) – Indexes that are ignored when calculating loss

  • smoothing (float) – ratio of smoothing (confidence = 1.0 - smoothing)

  • dim (int) – dimension of calculation loss

  • reduction (str) – reduction method [sum, mean] (default: sum)

Inputs: logits, target

logits (torch.Tensor): probability distribution value from model and it has a logarithm shape target (torch.Tensor): ground-thruth encoded to integers which directly point a word in label

Returns: label_smoothed
  • label_smoothed (float): sum of loss