Expected object of scalar type Long but got scalar type Int for argument #2 'target'
程序员文章站
2022-06-13 08:00:24
...
Exception has occurred: RuntimeError
Expected object of scalar type Long but got scalar type Int for argument #2 'target'
方法一:
targets =torch.LongTensor(targets)
方法二:
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
targets = targets.to(device,dtype=torch.int64)
上一篇: Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got torch.cuda.FloatTensor i
下一篇: mysql连接报时间问题
推荐阅读
-
报错:Expected object of scalar type Float but got scalar type Long for argument #2 'target'
-
RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got CUDAType
-
RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #2 'target'
-
RuntimeError: Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got CUDAFloatT
-
RuntimeError: Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got torch.IntT
-
Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got torch.cuda.FloatTensor i
-
Expected object of scalar type Long but got scalar type Int for argument #2 'target'
-
RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'target'
-
Expected object of scalar type Long but got scalar type Double for argument #2 'target'
-
Expected object of scalar type Float but got scalar type Long for argument #2 'target'