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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user