问题一:
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.
问题二:
报错:
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)