From ae7aff2e9cf6c79cf61e18cdc60ce68cf9f98400 Mon Sep 17 00:00:00 2001
From: majic31 <majic31@163.com>
Date: 星期二, 24 十二月 2024 17:51:11 +0800
Subject: [PATCH] fix: solve problems in sensevoice_bin.py related to argmax and unique, as mentioned in issue #2331 (#2332)

---
 funasr/train_utils/model_summary.py |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/funasr/train_utils/model_summary.py b/funasr/train_utils/model_summary.py
index 2aef88a..842cd21 100644
--- a/funasr/train_utils/model_summary.py
+++ b/funasr/train_utils/model_summary.py
@@ -47,8 +47,18 @@
 def model_summary(model: torch.nn.Module) -> str:
     message = "Model structure:\n"
     message += str(model)
-    tot_params = sum(p.numel() for p in model.parameters())
-    num_params = sum(p.numel() for p in model.parameters() if p.requires_grad)
+
+    tot_params, num_params = 0, 0
+    for name, param in model.named_parameters():
+        print(
+            "name: {}, dtype: {}, device: {}, trainable: {}, shape: {}, numel: {}".format(
+                name, param.dtype, param.device, param.requires_grad, param.shape, param.numel()
+            )
+        )
+        tot_params += param.numel()
+        if param.requires_grad:
+            num_params += param.numel()
+
     percent_trainable = "{:.1f}".format(num_params * 100.0 / tot_params)
     tot_params = get_human_readable_count(tot_params)
     num_params = get_human_readable_count(num_params)

--
Gitblit v1.9.1