大佬你好,我在使用swin模块时出现以下错误:
File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, kwargs)
File "/home/hhch/NewIdea/yolov5-master/models/transformer.py", line 205, in forward
return self.cv3(torch.cat((self.m(self.cv1(x)), self.cv2(x)), dim=1))
File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, *kwargs)
File "/home/hhch/NewIdea/yolov5-master/models/transformer.py", line 158, in forward
x = self.tr(x)
File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(input, kwargs)
File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, *kwargs)
File "/home/hhch/NewIdea/yolov5-master/models/swintransform.py", line 242, in forward
attn_windows = self.attn(x_windows, mask=attn_mask) # nWB, window_sizewindow_size, C
File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(input, **kwargs)
File "/home/hhch/NewIdea/yolov5-master/models/swintransform.py", line 87, in forward
x = (attn @ v).transpose(1, 2).reshape(B_, N, C)
RuntimeError: expected scalar type Float but found Half
这是为啥呀
大佬你好,我在使用swin模块时出现以下错误: File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, kwargs) File "/home/hhch/NewIdea/yolov5-master/models/transformer.py", line 205, in forward return self.cv3(torch.cat((self.m(self.cv1(x)), self.cv2(x)), dim=1)) File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "/home/hhch/NewIdea/yolov5-master/models/transformer.py", line 158, in forward x = self.tr(x) File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, kwargs) File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward input = module(input) File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "/home/hhch/NewIdea/yolov5-master/models/swintransform.py", line 242, in forward attn_windows = self.attn(x_windows, mask=attn_mask) # nWB, window_sizewindow_size, C File "/home/hhch/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, **kwargs) File "/home/hhch/NewIdea/yolov5-master/models/swintransform.py", line 87, in forward x = (attn @ v).transpose(1, 2).reshape(B_, N, C) RuntimeError: expected scalar type Float but found Half 这是为啥呀