解决错误:RuntimeError: result type Float can‘t be cast to the desired output type __int64

文章目录


文章来源参考:顾悦西
解决错误:RuntimeError: result type Float can‘t be cast to the desired output type __int64_第1张图片
解决错误:RuntimeError: result type Float can‘t be cast to the desired output type __int64_第2张图片
解决方式:
将loss.py中gain = torch.ones(7, device=targets.device)改为gain = torch.ones(7, device=targets.device).long()即可。原因是新版本的torch无法自动执行此转换,旧版本torch可以

loss.py在utils文件夹下,ctrl+f搜索gain,找到gain = torch.ones(7, device=targets.device),将其修改为gain = torch.ones(7, device=targets.device).long(),问题解决
解决错误:RuntimeError: result type Float can‘t be cast to the desired output type __int64_第3张图片

你可能感兴趣的:(yolo,YOLO)