Преглед изворни кода

Merge pull request #1161 from alibaba-damo-academy/dev_lhn

fix loss normalization for ddp training
hnluo пре 2 година
родитељ
комит
202ab8a2c9
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      funasr/models/e2e_uni_asr.py

+ 1 - 1
funasr/models/e2e_uni_asr.py

@@ -442,7 +442,7 @@ class UniASR(FunASRModel):
         stats["loss"] = torch.clone(loss.detach())
         stats["loss"] = torch.clone(loss.detach())
         # force_gatherable: to-device and to-tensor if scalar for DataParallel
         # force_gatherable: to-device and to-tensor if scalar for DataParallel
         if self.length_normalized_loss:
         if self.length_normalized_loss:
-            batch_size = (text_lengths + 1).sum().type_as(batch_size)
+            batch_size = int((text_lengths + 1).sum())
         loss, stats, weight = force_gatherable((loss, stats, batch_size), loss.device)
         loss, stats, weight = force_gatherable((loss, stats, batch_size), loss.device)
         return loss, stats, weight
         return loss, stats, weight