kukulaiyiyi 2023-09-06 16:18 采纳率: 0%
浏览 591

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

报错: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),我根据他们的解决方法相应地变换着试了一下,都不行还是会报这个错!有兄弟说一说解决方法吗?

  • 写回答

4条回答 默认 最新

  • 发豪·€ 2023-10-20 12:35
    关注

    正解就是一个在CPU上,一个在GPU上,导致两个计算精度不一样

    评论

报告相同问题?

问题事件

  • 创建了问题 9月6日

悬赏问题

  • ¥20 MC9S12XS128单片机开发板实验,
  • ¥15 C#多线程假死或卡死问题
  • ¥15 关于#tcp/ip#的问题:苹果电脑M1,easyconnect登录成功,显示虚拟 IP 地址
  • ¥15 客户端发现不了OPC服务器
  • ¥35 spaceclaim脚本
  • ¥500 寻找华为新款路由器开telnet方法
  • ¥20 运行pointnerf模型遇到了pycuda的错误,如何解决?(相关搜索:测试代码|自动驾驶|数据集)
  • ¥15 失败的github程序安装
  • ¥15 WSL上下载的joern在windows怎么用?
  • ¥15 jetson nano4GB