游雁
2024-04-29 8f596af4be1c2e5c4e4b4a7008ba96f412d40fca
funasr/models/sense_voice/model.py
@@ -1,3 +1,4 @@
import logging
from dataclasses import dataclass
from typing import Dict
from typing import Iterable, Optional
@@ -308,7 +309,7 @@
        if len(speech_lengths.size()) > 1:
            speech_lengths = speech_lengths[:, 0]
        batch_size = speech.shape[0]
        batch_size, frames, _ = speech.shape
        if self.activation_checkpoint:
            from torch.utils.checkpoint import checkpoint
@@ -327,6 +328,9 @@
        stats["acc"] = acc_att
        stats["loss"] = torch.clone(loss.detach())
        stats["batch_size"] = batch_size
        stats["batch_size_x_frames"] = frames * batch_size
        stats["batch_size_real_frames"] = speech_lengths.sum().item()
        stats["padding_frames"] = stats["batch_size_x_frames"] - stats["batch_size_real_frames"]
        # force_gatherable: to-device and to-tensor if scalar for DataParallel
        if self.length_normalized_loss: