The fix that saved me countless hours: Always explicitly cast your data types early in your pipeline: X = torch.tensor (X, dtype=torch.float32) y = torch.tensor (y, dtype=torch.long) # for ...