【个人笔记】

问题一:

yolov5中添加CBAM后出现报错:

RuntimeError: adaptive max pool2d backward cuda does not have a deterministic implementation, but you set torch use deterministic algorithms(True)'. You can turn off determinism just for this operation, or you can use the ' warn only-True' option, if that's acceptable for your application. You can also file an issue at https://github. con/pytorch/pytorch/issues to he lp us prioritize adding deterministic support for this operation.

 解决方法:(44条消息) 添加CBAM注意力机制报错:RuntimeError: adaptive_max_pool2d_backward_cuda does not have a deterministic implemen_weixin_46135327的博客-CSDN博客

问题二:

报错:

File "/home/junfeng/miniconda3/envs/py_hxw/lib/python3.10/site-packages/torch/nn/modules/conv. py", line 459, in _conv_forward return F. conv2d(input, weight, bias, self. stride,

RuntimeError: Input type (float) and bias type (c10:: Half) should be the same

 解决方法:bias = bias.float。将bias类型转为浮点型

但在之后会报错:AttributeError: 'NoneType' object has no attribute 'float'。

在使用`F.conv2d`进行卷积操作时,可以选择是否使用偏置。如果不使用偏置,则`bias`为`None`。因此,如果在使用`bias.float()`时,`bias`为`None`,就会出现`AttributeError: 'NoneType' object has no attribute 'float'`的错误。
解决方法是在调用`F.conv2d`函数时,判断`bias`是否为`None`。如果`bias`为`None`,则不使用偏置;否则,使用偏置并将其转换为float类型。可以使用下面的代码来实现:

if bias is not None:
    bias = bias.float()
return F.conv2d(input, weight, bias, self.stride,
                self.padding, self.dilation, self.groups)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值