原文:Expected tensor for argument #1 'indices' to have scalar type Long; but got CUDAFloatTensor instead

运行代码时出现此问题,参数类型的错误 传的参数应该是torch.longtensor类型 使用a torch.LongTensor 定义即可 ...

2018-11-10 15:15 0 6421 推荐指数:

查看详情

expected scalar type Long but found Float

Pytorch tensor と numpy ndarray の変換 - Pythonいぬ (hatenablog.com) 主要还是 array 转 tensor的时候要确定类型 x = torch.from_numpy(x.astype(np.float32)) ...

Sat Oct 16 20:06:00 CST 2021 0 1318
[已解决]报错:ValueError: Expected 2D array, got scalar array instead

报错代码: 报错结果: 解决思路: 值错误:应为二维数组,而得到的是一维数组: 使用array重新调整数据的形状。如果数据有单个功能或数组,则重新调整形状(-1,1)。如果数据包含单个示 ...

Wed Aug 07 01:04:00 CST 2019 0 2892
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM