错误:Runtime error: expected scalar type Float but found Double

w_true=torch.tensor([2,-3.4]).T
b_true=4.2
feature = torch.from_numpy(np.random.normal(0,1,(num_input,num_example)))
#feature = torch.float32(feature)
labels = torch.matmul(w_true.T,feature)+b_true

问题:Runtime error: expected scalar type Float but found Double
原因:np.random.rand()生成的数据是float64的,而torch默认是float32,于是就出现了问题
解决办法

feature = torch.from_numpy(np.float32(np.random.normal(0,1,(num_input,num_example))))

Runtime error: expected scalar type Float but found Double相关推荐

  1. expected scalar type float but found half

    expected scalar type float but found half 这个问题很明显就是网络内的参数类型不同意: 修改: 在前面添加:这个我测试没成功 torch.set_default ...

  2. 使用PyTorch前向运算时出现“RuntimeError: Expected object of scalar type Long but got scalar type Float for ……”

    1 问题描述 今天在使用PyTorch搭建模型时,出现了一个问题: RuntimeError: Expected object of scalar type Long but got scalar t ...

  3. expected scalar type Double but found Float

    RuntimeError: expected scalar type Double but found Float 原因:tensor的数据类型不正确 解决: 将数据类型转为float32 并不是因为 ...

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

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

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

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

  6. RuntimeError: expected scalar type Double but found Float

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

  7. 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 ...

  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. NR 5G 网络功能之AMF
  2. 各种页面刷新代码大全,asp/javascript刷新页面代码
  3. 单片机数据在网页上显示_不务正业的Excel也玩地图,在地图上显示数据,好玩又简单...
  4. [Bugku CTF——Pwn] pwn2
  5. 唯一标识计算机的位置目录与文件的是,计算机应用基础 7.doc
  6. 前端:JS/17/前篇总结(JS程序的基本语法,变量),数据类型-变量的类型(数值型,字符型,布尔型,未定义型,空型),数据类型转换,typeof()判断数据类型,从字符串提取整数或浮点数的函数
  7. django 指令  基于the django book
  8. [后端人员耍前端系列]AngularJs篇:使用AngularJs打造一个简易权限系统
  9. 使用 Litho 改进 News Feed 上的 Android 视频表现
  10. 还在找一款编辑友好,美观方便的开源wiki系统?安利一款超好用wiki
  11. 鹿客、小米、智汀、德施曼这几款热门智能门锁测评:谁最安全?谁最便捷?
  12. php坏处,cpu超频有什么坏处
  13. 需求与商业模式分析-6-五个课题
  14. 机器学习之集成学习(七)随机森林scikit-learn库
  15. 鸡啄米:C++编程入门系列之目录和总结http://www.jizhuomi.com/software/129.html
  16. cairo填充_Cairo图形指南
  17. C++图像处理OpenCV之屠龙宝刀第11篇 —— opencv_contrib(OpenCV贡献库)
  18. 家用洗地机哪款好?家用洗地机好用品牌推荐
  19. 汽车诊断之UDS入门-0x11(ECUReset)ECU重置
  20. Matlab:Matlab编程语言应用之三维绘图可视化(基础知识点基本函)的使用方法简介、案例实现(三维曲线图机械阻尼振动三维等高线图等案例)之详细攻略

热门文章

  1. go 计算两个时间的时间差
  2. python中logging库使用总结
  3. 万字长文详解目标检测算法,超大超全(2022最新)
  4. 【三维目标检测】3DSSD(二)
  5. 如何将计算机桌面屏幕放大,电脑桌面内容放大怎么缩小
  6. 金融行业的数据分析怎么做?
  7. 查询条件中含有加号_中国邮储银行信用卡公众号账单查询
  8. Python最强干货,建议收藏!!
  9. python实现屏幕视频录制_用Python来做一个屏幕录制工具
  10. 桌面应用程序脚本录制