fix(sconet): convert label_ids to CUDA LongTensor

- ScoNet:
  - Previously, `label_ids` remained a NumPy array, which could cause dtype/device mismatches when used with PyTorch tensors on GPU.
  - Convert `label_ids` to `torch.from_numpy(...).cuda().long()` to ensure correct tensor type (Long) and device (CUDA), aligning with loss functions that expect class indices on the same device.
This commit is contained in:
Zzier
2025-10-28 17:45:00 +08:00
parent 11513c3744
commit 28d4edc647
+2 -1
View File
@@ -20,7 +20,8 @@ class ScoNet(BaseModel):
# Label mapping: negative->0, neutral->1, positive->2
label_ids = np.array([{'negative': 0, 'neutral': 1, 'positive': 2}[status] for status in labels])
label_ids = torch.from_numpy(label_ids).cuda().long()
sils = ipts[0]
if len(sils.size()) == 4:
sils = sils.unsqueeze(1)