当前位置:网站首页>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:35:00 【booze-J】
运行代码:
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个channel,1行,3列
targets = torch.reshape(targets,(1,1,1,3))
loss = L1Loss()
result = loss(inputs,targets)
print(result)
报错RuntimeError: mean(): input dtype should be either floating point or complex dtypes. Got Long instead.
出问题的代码:
inputs = torch.tensor([1,2,3])
targets = torch.tensor([1,2,5])
修改数据类型
inputs = torch.tensor([1,2,3],dtype=torch.float32)
targets = torch.tensor([1,2,5],dtype=torch.float32)
再次运行:

边栏推荐
- 2022 t elevator repair question bank and simulation test
- 206. reverse linked list
- Tcp/ip explanation (version 2) notes / 3 link layer / 3.4 bridge and switch / 3.4.2 multiple registration protocol (MRP)
- 软件研发的十大浪费:研发效能的另一面
- [learn C and fly] S1E20: two dimensional array
- Obtain detailed ideas for ABCDEF questions of 2022 American Games
- Basic exercise of test questions hexadecimal to decimal
- The junior college students were angry for 32 days, four rounds of interviews, five hours of soul torture, and won Ali's offer with tears
- 2022危险化学品生产单位安全生产管理人员题库及答案
- CF1638E colorful operations
猜你喜欢

CF1638E colorful operations

Use winmtr software to simply analyze, track and detect network routing

Pytorch(三) —— 函数优化

(12) Somersault cloud case (navigation bar highlights follow)

【硬十宝典】——2.【基础知识】开关电源各种拓扑结构的特点

I also gave you the MySQL interview questions of Boda factory. If you need to come in and take your own

How to do the performance pressure test of "Health Code"

LM小型可编程控制器软件(基于CoDeSys)笔记二十:plc通过驱动器控制步进电机

Internet winter, how to spend three months to make a comeback

Kodori tree board
随机推荐
Simple implementation of slf4j
One job hopping up 8K, three times in five years
Possible problems and solutions of using scroll view to implement slider view
Embedded System Development Notes 79: why should I get the IP address of the local network card
[Master / slave] router election in DD message
OdeInt与GPU
Collect the annual summary of laws, regulations, policies and plans related to trusted computing of large market points (national, ministerial, provincial and municipal)
2022-02-15 (399. Division evaluation)
Use winmtr software to simply analyze, track and detect network routing
Mallbook: how can hotel enterprises break the situation in the post epidemic era?
Difference between cookie and session
Embedded System Development Notes 80: using QT designer to design the main interface
Task04 mathematical statistics
2022年煤气考试题库及在线模拟考试
如何看待智慧城市建设中的改变和机遇?
Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com. and
Why is Hong Kong server most suitable for overseas website construction
2022年T电梯修理题库及模拟考试
MySQL winter vacation self-study 2022 12 (5)
软件研发的十大浪费:研发效能的另一面