当前位置:网站首页>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 :
边栏推荐
猜你喜欢
Extension fragment
[godot] unity's animator is different from Godot's animplayer
Use of dataloader
分布式全局唯一ID解决方案详解
Kodori tree board
神经网络-卷积层
2022 hoisting machinery command registration examination and hoisting machinery command examination registration
【硬十宝典】——1.【基础知识】电源的分类
Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling
Section 27 remote access virtual private network workflow and experimental demonstration
随机推荐
Pytorch(一) —— 基本语法
LeetCode_28(实现 strStr())
[godot] unity's animator is different from Godot's animplayer
How to do the performance pressure test of "Health Code"
洗个冷水澡吧
分布式锁的实现
OdeInt與GPU
RuntimeError: “max_pool2d“ not implemented for ‘Long‘
LeetCode_66(加一)
TCP server communication flow
Openresty rewrites the location of 302
Basic usage, principle and details of session
STM32扩展板 数码管显示
2022 Shanghai safety officer C certificate examination question simulation examination question bank and answers
Kodori tree board
【FTP】FTP连接时出现“227 Entering Passive Mode”的解决方法
How to use maixll dock
分布式架构系统拆分原则、需求、微服务拆分步骤
LeetCode_ 53 (maximum subarray and)
Use of dataloader