RuntimeError: expected scalar type Double but found Float

原因:tensor的数据类型不正确
解决: 将数据类型转为float32
并不是因为他expected Double你就要弄成Double
查了一些博文说
tensor.to(torch.float32)
但其实这里面的tensor指的是tensor类型的数据
在你自己的代码上他可能是x可能是data
这个要你自己多尝试
我的是x.to(torch.float32)
torch里有一些Bug
还有包括target后面要接.long()
分享出来希望帮到大家

expected scalar type Double but found Float相关推荐

  1. [报错]RuntimeError: expected scalar type Double but found Float(torch)

    RuntimeError: expected scalar type Double but found Float 在使用torch训练模型的时候,发现该问题.根据提示,是双精度和float之间的冲突 ...

  2. RuntimeError: expected scalar type Double but found Float

    最近在使用 sequitur库 快速搭建自编码器时遇到 RuntimeError: expected scalar type Double but found Float 涉及代码 import to ...

  3. 报错:RuntimeError: expected scalar type Double but found Float

    这个问题是深度学习,用pytorch跑的时候出现的 解决办法:这个是格式问题,希望的格式是double,但得到的是float.字面意思是这个,但是并不是非要把格式改成double,这个时候应该在出错的 ...

  4. 解决pytorch当中RuntimeError: expected scalar type Double but found Float的问题

    出现这个问题的原因可能是因为tensor的数据类型不对,有可能是反向传播中输入x的类型不对,也有可能是训练和测试过程中的data类型不对,如果是反向传播过程的话,那就要看是哪一层神经网络出现问题,就在 ...

  5. 常见报错:RuntimeError: expected scalar type Long but found Float

    RuntimeError: expected scalar type Long but found Float 这是一个非常常见的报错,我已经遇到过这个报错很多次了,但是之前没有仔细研究过,今天好好好 ...

  6. output = input.matmul(weight.t()) RuntimeError: expected scalar type Long but found Float 错误解决

    在使用pytorch的nn.Linear时出现错误 RuntimeError: expected scalar type Long but found Float 这里报错的原因是我的输入是Longt ...

  7. RuntimeError: expected scalar type Half but found Float

    起因:将CCNet的十字交叉注意力模块移植到YOLOv5中. 经过:在注意力模块中,会有较多的矩阵运算,在训练时出现了cuda和cup类型的冲突(另一篇我写的文章):而在验证时出现了上述错误. 出错的 ...

  8. 解决pytorch RuntimeError: expected scalar type XXXX but found XXXX

    比如报错为:RuntimeError: expected scalar type Long but found Float,就是希望输入为torch.Long,结果得到一个torch.Float 解决 ...

  9. expected scalar type Long but found Int

    报错信息 expected scalar type Long but found Int 或者 expected scalar type Long but found Float 报错场景 pytor ...

最新文章

  1. fastjson到底做错了什么?为什么会被频繁爆出漏洞?
  2. Python_面试题
  3. uva 10883——Supermean
  4. linux安装selenium、chromedriver、Chrome浏览器、BrowserMob Proxy(代理)爬虫爬站环境安装及测试实例
  5. 20200621每日一句
  6. 用python调用r包
  7. latex 如何添加圆圈数字?
  8. 希尔加密法matlab,希尔密码加密解密
  9. 基础算法:数的三次方根—浮点二分
  10. 第三方定量定性质谱检测技术实验
  11. 手机卡从2G升级到4G,那GSM、WCDMA和LTE这些词你都了解吗?
  12. com.lbx:xTools
  13. 【3】天猫精灵开放实验平台实验— 切换意图,参数传递
  14. 手机直播/PC直播/摄像头直播等流媒体直播系统中如何进行推流优化?
  15. java动态分配空间吗,当执行new为一个对象分配内存时,Java()A、自动初始化所分配的内存空间B、只分配内存,初始化要...
  16. Gardner定时同步的matlab实现
  17. oracle rank 语法_Oracle排名函数(Rank)实例详解
  18. Ramnit感染型蠕虫病毒专杀工具
  19. java 缓存ByteBuffer
  20. php导出表格是乱码怎么办,数据库导出excel表格是乱码怎么办-Excel表格乱码问题怎么解决?...

热门文章

  1. Linux学习——废旧电脑再利用Ubuntu部署私有云Nextcloud
  2. java小程序贪吃蛇代码_微信小程序Demo之贪食蛇
  3. 用好这 28 个工具,开发效率爆涨|云效工程师指北
  4. AP计算机从绝望到满分-----深圳中学张嘉轩如何说
  5. 深蓝色固体Cyanine5-Azide,Cy5-N3,Cy5 Azide,菁染料CY5叠氮
  6. 全球与中国医疗3D打印机市场深度研究分析报告
  7. vue2.0 日历日程表 ,可进行二次开发.
  8. Python实例---爬取下载喜马拉雅音频文件
  9. Debian Etch 源配置
  10. 第三单元 用python学习微积分(二十二)功、平均值、概率(下)和 数值积分(1)