From 6e0d1388264f79ce5e2a3c8944de1bad491d30eb Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期日, 09 六月 2024 03:26:32 +0800
Subject: [PATCH] fix bug
---
funasr/datasets/openai_datasets/datasets.py | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/funasr/datasets/openai_datasets/datasets.py b/funasr/datasets/openai_datasets/datasets.py
index 0d12a1c..e13c156 100644
--- a/funasr/datasets/openai_datasets/datasets.py
+++ b/funasr/datasets/openai_datasets/datasets.py
@@ -162,7 +162,7 @@
if badcase_flag:
continue
input_ids = torch.tensor(input_ids, dtype=torch.int64) # [: self.max_token_length]
- attention_mask = torch.tensor([len(input_ids)], dtype=torch.int32)
+ attention_mask = torch.tensor([1] * len(input_ids), dtype=torch.int32)
labels = torch.tensor(labels, dtype=torch.int64) # [: self.max_token_length]
fbank = speech[0, :, :]
@@ -211,14 +211,15 @@
if self.batch_type != "example":
b, t = outputs["input_ids"].shape
- if b * t > self.batch_size * self.batch_size_scale_ratio_max:
- beg = torch.randint(0, 2, ()).item()
- if b < 2:
- beg = 0
+ if b > 1 and b * t > self.batch_size * self.batch_size_scale_ratio_max:
+ # beg = torch.randint(0, 2, ()).item()
+ # if b < 2:
+ # beg = 0
logging.info(
- f"Warning, b * t: {b * t} > {self.batch_size}, b: {b}, t: {t}, drop half data {idx}th, beg:{beg}"
+ f"Warning, b*t: {b}*{t}={b * t} > batch_size*relax: {self.batch_size_scale_ratio_max}*{self.batch_size}={self.batch_size_scale_ratio_max*self.batch_size}, drop half data {idx}th, beg:{beg}"
)
- samples = samples[beg : beg + b : 2]
+ # samples = samples[beg : beg + b : 2]
+ samples = samples[:-1]
continue
break
--
Gitblit v1.9.1