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的返回的值的类型
划线部位改为:torchLongTensor(np.array(lbl[:5]))
即:
总之就是要把数据改为long的类型。