RuntimeError: result type Float can’t be cast to the desired output type long int

yolov5模型训练时候报错。

通过错误信息定位到loss.py文件错误位置:

indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) 

在gain[3]和gain[2]后面增加.long()进行类型转换:

indices.append((b, a, gj.clamp_(0, gain[3].long() - 1), gi.clamp_(0, gain[2].long() - 1)))

你可能感兴趣的:(python,yolov5,loss)