From 6e69d784e4814c3dbe35e8f70c6cf4b920c8b20b Mon Sep 17 00:00:00 2001
From: 天地 <tiandiweizun@gmail.com>
Date: 星期三, 19 三月 2025 23:10:13 +0800
Subject: [PATCH] 1. bug fix:list(mean)和list(var),由于mean和var是numpy,导致写入到文件的格式错误,参考上面的话,大概率是list(mean.tolist()),其实外层list没有必要 (#2437)
---
funasr/losses/label_smoothing_loss.py | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/funasr/losses/label_smoothing_loss.py b/funasr/losses/label_smoothing_loss.py
index 385025d..ffc38da 100644
--- a/funasr/losses/label_smoothing_loss.py
+++ b/funasr/losses/label_smoothing_loss.py
@@ -65,11 +65,7 @@
class SequenceBinaryCrossEntropy(nn.Module):
- def __init__(
- self,
- normalize_length=False,
- criterion=nn.BCEWithLogitsLoss(reduction="none")
- ):
+ def __init__(self, normalize_length=False, criterion=nn.BCEWithLogitsLoss(reduction="none")):
super().__init__()
self.normalize_length = normalize_length
self.criterion = criterion
@@ -95,7 +91,7 @@
size,
padding_idx,
normalize_length=False,
- criterion=nn.NLLLoss(reduction='none'),
+ criterion=nn.NLLLoss(reduction="none"),
):
"""Construct an NllLoss object."""
super(NllLoss, self).__init__()
@@ -122,6 +118,6 @@
ignore = target == self.padding_idx # (B,)
total = len(target) - ignore.sum().item()
target = target.masked_fill(ignore, 0) # avoid -1 index
- kl = self.criterion(x , target)
+ kl = self.criterion(x, target)
denom = total if self.normalize_length else batch_size
return kl.masked_fill(ignore, 0).sum() / denom
--
Gitblit v1.9.1