Output 0 of SelectBackward0 is a view and is being modified inplace

在运行Yolov5的detect_3d_cls.py脚本时遇到了一个运行时错误,错误信息指出Output0ofSelectBackward0是一个视图并正在原地被修改。问题出在对宽度和高度的条件检查中尝试进行原地修改。解决方案是在相关代码行前添加@torch.no_grad()装饰器,以避免在梯度计算过程中修改视图。
摘要由CSDN通过智能技术生成

yolov5运行报错,

Output 0 of SelectBackward0 is a view and is being modified inplace

  File "D:\project\detect\yolov5_wx_55681\det_check\detect_3d_cls.py", line 110, in run
    pred = non_max_suppression(pred, conf_thres, iou_thres, opt.classes, opt.agnostic_nms, max_det=max_det)
  File "D:\project\detect\yolov5_wx_55681\utils\general.py", line 728, in non_max_suppression
    x[((x[..., 2:4] < min_wh) | (x[..., 2:4] > max_wh)).any(1), 4] = 0  # width-height
RuntimeError: Output 0 of SelectBackward0 is a view and is being modified inplace. This view is the output of a function that returns multiple views. Such functions do not allow the output views to be modified inplace. You should replace the inplace operation by an out-of-place one.
 

解决方法:需要加上@torch.no_grad()

@torch.no_grad()
def run(opt):
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值