Runtime error: expected scalar type Float but found Double
错误: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相关推荐
- expected scalar type float but found half
expected scalar type float but found half 这个问题很明显就是网络内的参数类型不同意: 修改: 在前面添加:这个我测试没成功 torch.set_default ...
- 使用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 ...
- expected scalar type Double but found Float
RuntimeError: expected scalar type Double but found Float 原因:tensor的数据类型不正确 解决: 将数据类型转为float32 并不是因为 ...
- 常见报错:RuntimeError: expected scalar type Long but found Float
RuntimeError: expected scalar type Long but found Float 这是一个非常常见的报错,我已经遇到过这个报错很多次了,但是之前没有仔细研究过,今天好好好 ...
- [报错]RuntimeError: expected scalar type Double but found Float(torch)
RuntimeError: expected scalar type Double but found Float 在使用torch训练模型的时候,发现该问题.根据提示,是双精度和float之间的冲突 ...
- RuntimeError: expected scalar type Double but found Float
最近在使用 sequitur库 快速搭建自编码器时遇到 RuntimeError: expected scalar type Double but found Float 涉及代码 import to ...
- 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 ...
- 解决pytorch RuntimeError: expected scalar type XXXX but found XXXX
比如报错为:RuntimeError: expected scalar type Long but found Float,就是希望输入为torch.Long,结果得到一个torch.Float 解决 ...
- expected scalar type Long but found Int
报错信息 expected scalar type Long but found Int 或者 expected scalar type Long but found Float 报错场景 pytor ...
最新文章
- NR 5G 网络功能之AMF
- 各种页面刷新代码大全,asp/javascript刷新页面代码
- 单片机数据在网页上显示_不务正业的Excel也玩地图,在地图上显示数据,好玩又简单...
- [Bugku CTF——Pwn] pwn2
- 唯一标识计算机的位置目录与文件的是,计算机应用基础 7.doc
- 前端:JS/17/前篇总结(JS程序的基本语法,变量),数据类型-变量的类型(数值型,字符型,布尔型,未定义型,空型),数据类型转换,typeof()判断数据类型,从字符串提取整数或浮点数的函数
- django 指令 基于the django book
- [后端人员耍前端系列]AngularJs篇:使用AngularJs打造一个简易权限系统
- 使用 Litho 改进 News Feed 上的 Android 视频表现
- 还在找一款编辑友好,美观方便的开源wiki系统?安利一款超好用wiki
- 鹿客、小米、智汀、德施曼这几款热门智能门锁测评:谁最安全?谁最便捷?
- php坏处,cpu超频有什么坏处
- 需求与商业模式分析-6-五个课题
- 机器学习之集成学习(七)随机森林scikit-learn库
- 鸡啄米:C++编程入门系列之目录和总结http://www.jizhuomi.com/software/129.html
- cairo填充_Cairo图形指南
- C++图像处理OpenCV之屠龙宝刀第11篇 —— opencv_contrib(OpenCV贡献库)
- 家用洗地机哪款好?家用洗地机好用品牌推荐
- 汽车诊断之UDS入门-0x11(ECUReset)ECU重置
- Matlab:Matlab编程语言应用之三维绘图可视化(基础知识点基本函)的使用方法简介、案例实现(三维曲线图机械阻尼振动三维等高线图等案例)之详细攻略