当前位置:网站首页>RuntimeError: “max_pool2d“ not implemented for ‘Long‘
RuntimeError: “max_pool2d“ not implemented for ‘Long‘
2022-07-01 04:45:00 【booze-J】
Sample code :
import torch
# The input image (5X5)
from torch import nn
from torch.nn import MaxPool2d
# RuntimeError: "max_pool2d" not implemented for 'Long' This error is a data type error , So we need a input Add a data type restriction
input = torch.tensor([[1,2,0,3,1],
[0,1,2,3,1],
[1,2,1,0,0],
[5,2,3,1,1],
[2,1,0,1,1]])
# from [ Official documents ](https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html#torch.nn.MaxPool2d) Given API You can know the details of use requirement The input of is four-dimensional
# (batch_size,channels,H,W)=(-1,1,5,5) The first one is -1 to -1 Is to let him calculate batch_size
input = torch.reshape(input,(-1,1,5,5))
print(input.shape)
# Building neural networks
class Booze(nn.Module):
# Inherit nn.Module The initialization
def __init__(self):
super(Booze, self).__init__()
self.maxpool1 = MaxPool2d(kernel_size=3,ceil_mode=True)
# rewrite forward function
def forward(self,x):
output = self.maxpool1(x)
return output
obj = Booze()
output = obj(input)
print(output)
An error occurs when running this code :RuntimeError: "max_pool2d" not implemented for 'Long'.
This error is a data type error , So we have to deal with this input Add a data type restriction .
The problem code is
input = torch.tensor([[1,2,0,3,1],
[0,1,2,3,1],
[1,2,1,0,0],
[5,2,3,1,1],
[2,1,0,1,1]])
This code . Put data type restrictions on it dtype=torch.float32. I'll change it to
input = torch.tensor([[1,2,0,3,1],
[0,1,2,3,1],
[1,2,1,0,0],
[5,2,3,1,1],
[2,1,0,1,1]],dtype=torch.float32)
Run the result again and no error will be reported .
边栏推荐
- Day 52 - tree problem
- 2022-02-15 (399. Division evaluation)
- Dataloader的使用
- How to view the changes and opportunities in the construction of smart cities?
- Applications and features of VR online exhibition
- VR线上展览所具备应用及特色
- Maixll-Dock 快速上手
- Ten wastes of software research and development: the other side of research and development efficiency
- STM32扩展板 温度传感器和温湿度传感器的使用
- 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
猜你喜欢

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

Measurement of quadrature axis and direct axis inductance of three-phase permanent magnet synchronous motor

Question bank and answers for chemical automation control instrument operation certificate examination in 2022

Daily algorithm & interview questions, 28 days of special training in large factories - the 13th day (array)

Simple implementation of slf4j

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

Maixll dock quick start

LM small programmable controller software (based on CoDeSys) note 19: errors do not match the profile of the target

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 t elevator repair new version test questions and t elevator repair simulation test question bank
随机推荐
Basic usage, principle and details of session
技术分享| 融合调度中的广播功能设计
2022 G2 power station boiler stoker examination question bank and G2 power station boiler stoker simulation examination question bank
Leecode record 1351 negative numbers in statistical ordered matrix
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
总结全了,低代码还需要解决这4点问题
JVM栈和堆简介
Shell之分析服务器日志命令集锦
Odeint and GPU
Measurement of quadrature axis and direct axis inductance of three-phase permanent magnet synchronous motor
Advanced application of ES6 modular and asynchronous programming
数据加载及预处理
最长递增子序列及最优解、动物总重量问题
常用的Transforms中的方法
Construction of Meizhou nursing laboratory: equipment configuration
2022 question bank and answers for safety production management personnel of hazardous chemical production units
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
[pat (basic level) practice] - [simple simulation] 1064 friends
Summary of testing experience - Testing Theory
解决qiankun中子应用外链文件无法获取