Gumpest / YOLOv5-Multibackbone-Compression

YOLOv5 Series Multi-backbone(TPH-YOLOv5, Ghostnet, ShuffleNetv2, Mobilenetv3Small, EfficientNetLite, PP-LCNet, SwinTransformer YOLO), Module(CBAM, DCN), Pruning (EagleEye, Network Slimming), Quantization (MQBench) and Deployment (TensorRT, ncnn) Compression Tool Box.
989 stars 201 forks source link

使用SwinTransformexpected scalar type Float but found Half #52

Closed supoman-lei closed 2 years ago

supoman-lei commented 2 years ago

大佬你好,我在使用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 这是为啥呀

supoman-lei commented 2 years ago

将nohalf设置为True就可以正常训练了