当前位置:网站首页>pytorch lstm时间序列预测问题踩坑「建议收藏」
pytorch lstm时间序列预测问题踩坑「建议收藏」
2022-07-31 18:40:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
这里写目录标题
1.做时间序列问题
2.问题
1.数据集自己做,为多个输入对应多个或一个输出
2.损失函数
注意:不能用交叉熵 nn.CrossEntropyLoss()
nn.CrossEntropyLoss()要求target目标值即真实值是标签,是torch.int64类型数据,即整数,不允许小数,如果输入小数会强行取整, 应该用
nn.MSELoss()
我在这个问题上纠结了很久,总是显示
RuntimeError: expected scalar type Long but found Float
导致我找了很久怎么样才能把torch.float64保留小数的情况下转成long,后来查资料torch.long就是torch.int64,简直变态 后来一点一点往上找才知道的这个错误
注意2:真实值(目标值)必须是两个维度,否则会警告,不会报错
增加维度方法:
1.torch.unsqueeze(tensor, dim)
2.numpy_array = .numpy_array [np.newaxis, :, :] # 原来维度(10, 13)——(1, 10, 13)
补充
np.unaqueeze总是报错,不明白为什么
3.准确率
分类问题是有准确率这个评价的,但是我训练的rnn,loss一直降低,但是准确率为0,才反应过来,回归问题很难达到完全一致
3.结果
这是测试集预测结果,前10步预测后1步,勉强可以
训练集结果:
之后需要 0.5. 根据上一步预测结果预测下一个——做不到,x为13个变量,y只有1个,无法用y作为下一个x
- 找一个预测结果评价指标
- transformer编码解码
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/127416.html原文链接:https://javaforall.cn
边栏推荐
- A common method and the use of selenium
- BOW/DOM(上)
- Unity 之 音频类型和编码格式介绍
- leetcode 665. Non-decreasing Array 非递减数列(中等)
- Kotlin coroutines: continuation, continuation interceptor, scheduler
- 性能优化:记一次树的搜索接口优化思路
- Apache EventMesh distributed event-driven multi-runtime
- Handling write conflicts under multi-master replication (3) - Convergence to a consistent state and custom conflict resolution logic
- MySQL---运算符
- cas与自旋锁(轻量级锁就是自旋锁吗)
猜你喜欢
Three.js入门
每日练习------随机产生一个1-100之间的整数,看能几次猜中。要求:猜的次数不能超过7次,每次猜完之后都要提示“大了”或者“小了”。
iNeuOS工业互联网操作系统,设备运维业务和“低代码”表单开发工具
九齐ny3p系列语音芯片替代国产方案KT148A性价比更高420秒长度
[Network Communication 3] Advantech Gateway Modbus Service Settings
学生管理系统第一天:完成登录退出操作逻辑 PyQt5 + MySQL5.8
Bika LIMS 开源LIMS集—— SENAITE的使用(检测流程)
Jiuqi ny3p series voice chip replaces the domestic solution KT148A, which is more cost-effective and has a length of 420 seconds
How programmers learn open source projects, this article tells you
MySQL---多表查询
随机推荐
Made with Flutter and Firebase!counter application
A common method and the use of selenium
迁移学习——Domain Adaptation
Apache EventMesh distributed event-driven multi-runtime
INeuOS industrial Internet operating system, the equipment operational business and "low code" form development tools
淘宝/天猫获得淘口令真实url API
多线程之锁
JD.com searches for products by keyword API
MySQL---聚合函数
微信小程序的路由拦截
go记录之——slice
【码蹄集新手村600题】不通过字符数组来合并俩个数字
[PIMF] OpenHarmony Thesis Club - Inventory of the open source Hongmeng tripartite library [3]
Bika LIMS 开源LIMS集—— SENAITE的使用(检测流程)
TestCafe总结
Teach you how to deploy Nestjs projects
Bika LIMS 开源LIMS集—— SENAITE的使用(检测流程)
MySQL - multi-table query
Basics of ResNet: Principles of Residual Blocks
Write a database document management tool based on WPF repeating the wheel (1)