querryton
2024-04-20 01df8f330ccc754223d5e2d688dc0a55d27f2dcc
funasr/losses/label_smoothing_loss.py
@@ -8,7 +8,7 @@
import torch
from torch import nn
from funasr.modules.nets_utils import make_pad_mask
from funasr.models.transformer.utils.nets_utils import make_pad_mask
class LabelSmoothingLoss(nn.Module):
@@ -50,8 +50,8 @@
        """
        assert x.size(2) == self.size
        batch_size = x.size(0)
        x = x.view(-1, self.size)
        target = target.view(-1)
        x = x.contiguous().view(-1, self.size)
        target = target.contiguous().view(-1)
        with torch.no_grad():
            true_dist = x.clone()
            true_dist.fill_(self.smoothing / (self.size - 1))