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

报错: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日

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路