原文: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