Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
TOLD/SOND: update SequenceBinaryCrossEntropy loss
志浩66880c2a1aeb
diff --git a/funasr/losses/label_smoothing_loss.py b/funasr/losses/label_smoothing_loss.pyindex 3ea34c048..c272ea879 100644--- a/funasr/losses/label_smoothing_loss.py+++ b/funasr/losses/label_smoothing_loss.py@@ -75,10 +75,10 @@ class SequenceBinaryCrossEntropy(nn.Module):self.criterion = criteriondef forward(self, pred, label, lengths):- pad_mask = make_pad_mask(lengths, maxlen=pred.shape[1])+ pad_mask = make_pad_mask(lengths, maxlen=pred.shape[1]).to(pred.device)loss = self.criterion(pred, label)denom = (~pad_mask).sum() if self.normalize_length else pred.shape[0]- return loss.masked_fill(pad_mask, 0).sum() / denom+ return loss.masked_fill(pad_mask.unsqueeze(-1), 0).sum() / denomclass NllLoss(nn.Module):