当前位置:网站首页>RuntimeError: mean(): input dtype should be either floating point or complex dtypes. Got Long instead
RuntimeError: mean(): input dtype should be either floating point or complex dtypes. Got Long instead
2022-07-01 04:45:00 【booze-J】
Run code :
import torch
from torch.nn import L1Loss
inputs = torch.tensor([1,2,3])
targets = torch.tensor([1,2,5])
inputs = torch.reshape(inputs,(1,1,1,3)) # 1batch_size,1 individual channel,1 That's ok ,3 Column
targets = torch.reshape(targets,(1,1,1,3))
loss = L1Loss()
result = loss(inputs,targets)
print(result)
Report errors RuntimeError: mean(): input dtype should be either floating point or complex dtypes. Got Long instead.
The code that went wrong :
inputs = torch.tensor([1,2,3])
targets = torch.tensor([1,2,5])
Change data type
inputs = torch.tensor([1,2,3],dtype=torch.float32)
targets = torch.tensor([1,2,5],dtype=torch.float32)
Run again :

边栏推荐
- Leecode records the number of good segmentation of 1525 strings
- LeetCode_ 35 (search insertion position)
- js解决浮点数相乘精度丢失问题
- Technology sharing | broadcast function design in integrated dispatching
- 2022年化工自动化控制仪表操作证考试题库及答案
- Shell之分析服务器日志命令集锦
- 洗个冷水澡吧
- C -- array
- 分布式锁的实现
- Quelques outils dont les chiens scientifiques pourraient avoir besoin
猜你喜欢

Ten wastes of software research and development: the other side of research and development efficiency

先有网络模型的使用及修改

Odeint and GPU

2022 hoisting machinery command registration examination and hoisting machinery command examination registration

STM32 photoresistor sensor & two channel AD acquisition

Difficulties in the development of knowledge map & the importance of building industry knowledge map
![[godot] unity's animator is different from Godot's animplayer](/img/51/48f40a7b6736d7f78040eabbbd3395.jpg)
[godot] unity's animator is different from Godot's animplayer

Pytorch(三) —— 函数优化

Fitness without equipment

神经网络-卷积层
随机推荐
js解决浮点数相乘精度丢失问题
Fitness without equipment
STM32 光敏电阻传感器&两路AD采集
AssertionError assert I.ndim == 4 and I.shape[1] == 3
JS rotation chart
JVM栈和堆简介
Thoughts on the construction of Meizhou cell room
MySQL winter vacation self-study 2022 12 (5)
Caijing 365 stock internal reference | the first IPO of Beijing stock exchange; the subsidiary of the recommended securities firm for gambling and gambling, with a 40% discount
2022危险化学品生产单位安全生产管理人员题库及答案
pytorch中常用数据集的使用方法
软件研发的十大浪费:研发效能的另一面
OdeInt與GPU
Common UNIX Operation and maintenance commands of shell
2022年聚合工艺考试题及模拟考试
The design points of voice dialogue system and the importance of multi round dialogue
数据加载及预处理
Quelques outils dont les chiens scientifiques pourraient avoir besoin
Talk about testdeploy
How to do the performance pressure test of "Health Code"