From 64aad9786a4531e2f16bc7d1c803300d54457eff Mon Sep 17 00:00:00 2001 From: yilv <874448085@qq.com> Date: Tue, 12 May 2026 09:45:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(model=5Ffinetune):=20=E4=B8=BA=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E5=BC=A0=E9=87=8F=E6=B7=BB=E5=8A=A0dtype=E4=B8=8E?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E5=8F=82=E6=95=B0=E5=AF=B9=E9=BD=90=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Signal_MAE/model_finetune.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Signal_MAE/model_finetune.py b/Signal_MAE/model_finetune.py index dc067e0..10e7175 100644 --- a/Signal_MAE/model_finetune.py +++ b/Signal_MAE/model_finetune.py @@ -171,6 +171,11 @@ class TF_MAE_Classifier(nn.Module): def forward(self, x, channel_mask=None, channel_ids=None): if x.dim() == 2: x = x.unsqueeze(1) + # 确保输入数据类型与模型参数类型一致 + param_dtype = next(self.encoder_model.parameters()).dtype + if x.dtype != param_dtype: + x = x.to(param_dtype) + x_norm = self.encoder_model.prepare_tokens(x) if torch.onnx.is_in_onnx_export():