当前位置:网站首页>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)
再次运行:

边栏推荐
- TCP/IP 详解(第 2 版) 笔记 / 3 链路层 / 3.4 桥接器与交换机 / 3.4.2 多属性注册协议(Multiple Registration Protocol (MRP))
- Day 52 - tree problem
- OSPF notes [dr and bdr]
- Note de développement du système embarqué 80: application du concepteur Qt à la conception de l'interface principale
- MySQL advanced -- you will have a new understanding of MySQL
- selenium打开chrome浏览器时弹出设置页面:Mircrosoft Defender 防病毒要重置您的设置
- Collect the annual summary of laws, regulations, policies and plans related to trusted computing of large market points (national, ministerial, provincial and municipal)
- How do I sort a list of strings in dart- How can I sort a list of strings in Dart?
- js 图片路径转换base64格式
- 2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis
猜你喜欢

Maixll-Dock 快速上手

VR线上展览所具备应用及特色

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

Simple implementation of slf4j

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

【LeetCode】100. Same tree
![[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(四) —— 可视化工具 Visdom

Threejs opening

Knowledge supplement: basic usage of redis based on docker
随机推荐
OdeInt與GPU
Cmake selecting compilers and setting compiler options
The index is invalid
CUDA development and debugging tool
Task04 mathematical statistics
Maixll dock quick start
2022 a special equipment related management (elevator) simulation test and a special equipment related management (elevator) certificate examination
Applications and features of VR online exhibition
2. Use of classlist (element class name)
Some small knowledge points
2022危险化学品生产单位安全生产管理人员题库及答案
Extension fragment
使用WinMTR软件简单分析跟踪检测网络路由情况
嵌入式系統開發筆記80:應用Qt Designer進行主界面設計
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
Question bank and answers for chemical automation control instrument operation certificate examination in 2022
[human version] Web3 privacy game in the dark forest
【深度学习】(4) Transformer 中的 Decoder 机制,附Pytorch完整代码
Registration for R2 mobile pressure vessel filling test in 2022 and R2 mobile pressure vessel filling free test questions
Registration of P cylinder filling examination in 2022 and analysis of P cylinder filling