RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #2 ‘target’
该错误两个关键点:
1.target
2.long
即target所使用的数据要改为long的类型。

我是在基于pytorch做一个视觉问题,该问题出在,在定义dataloader时,所用类型需要转换。
解决方案:
修改定义dataset时所用到的getitem的返回的值的类型
RuntimeError: Expected object of scalar type Long

划线部位改为:torchLongTensor(np.array(lbl[:5]))

即:
RuntimeError: Expected object of scalar type Long

总之就是要把数据改为long的类型。

相关文章:

  • 2021-07-22
  • 2022-12-23
  • 2021-06-10
  • 2022-12-23
  • 2021-06-22
  • 2021-08-20
  • 2022-12-23
  • 2021-08-16
猜你喜欢
  • 2021-06-12
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2021-06-01
  • 2022-12-23
相关资源
相似解决方案