RuntimeError: result type Float can‘t be cast to the desired output type Long

参考RuntimeError: result type Float can‘t be cast to the desired output type Long - 云+社区 - 腾讯云

使用BCEWithLogitsLoss()时RuntimeError: result type Float can't be cast to the desired output type Long

使用BCEWithLogitsLoss(output,target),output 为float类型,target为int64,报错RuntimeError: result type Float can't be cast to the desired output type Long

参考提问,提到

RuntimeError: result type Float can‘t be cast to the desired output type Long_第1张图片

改成BCEWithLogitsLoss(output,target.float())

我理解的是output和target的数据类型应一致,原本target为long类型,output为float,但是无法将output转为long,只能将target转为float。

 

你可能感兴趣的:(异常处理,计算机视觉,深度学习,机器学习)