报错:RuntimeError: Input type (c10::Half) and bias type (float) should be the same
代码问题如下:
Traceback (most recent call last):
File "/media/junfeng/D:/All_User_Code/SWH/yolov7-mains/train.py", line 619, in <module>
train(hyp, opt, device, tb_writer)
File "/media/junfeng/D:/All_User_Code/SWH/yolov7-mains/train.py", line 363, in train
pred = model(imgs) # forward
File "/home/junfeng/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/media/junfeng/D:/All_User_Code/SWH/yolov7-mains/models/yolo.py", line 628, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/media/junfeng/D:/All_User_Code/SWH/yolov7-mains/models/yolo.py", line 655, in forward_once
x = m(x) # run
File "/home/junfeng/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/media/junfeng/D:/All_User_Code/SWH/yolov7-mains/models/yolo.py", line 114, in forward
x[i] = self.asffs[i](*x)
File "/home/junfeng/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/media/junfeng/D:/All_User_Code/SWH/yolov7-mains/models/common.py", line 2478, in forward
fused_low, fused_high = fuse_features(level_0_resized, level_1_resized)
File "/media/junfeng/D:/All_User_Code/SWH/yolov7-mains/models/common.py", line 2414, in fuse_features
fused_high = nn.Conv2d(high_level.size(1), low_level.size(1), kernel_size=1)(high_level)
File "/home/junfeng/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/junfeng/.local/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 469, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/home/junfeng/.local/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 461, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Input type (c10::Half) and bias type (float) should be the same
我看了很多博客都是bias的类型是(c10::Half),我根据他们的解决方法相应地变换着试了一下,都不行还是会报这个错!有兄弟说一说解决方法吗?