当前位置:网站首页>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 .
边栏推荐
- Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling
- OdeInt與GPU
- [godot] unity's animator is different from Godot's animplayer
- 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
- Extension fragment
- 2022-02-15 (399. Division evaluation)
- How to do the performance pressure test of "Health Code"
- STM32 extended key scan
- [difficult] sqlserver2008r2, can you recover only some files when recovering the database?
- 先有网络模型的使用及修改
猜你喜欢

How to use maixll dock

Cmake selecting compilers and setting compiler options
![[ue4] event distribution mechanism of reflective event distributor and active call event mechanism](/img/44/6a26ad24d56ddd5156f3a31fa7e0b9.jpg)
[ue4] event distribution mechanism of reflective event distributor and active call event mechanism

pytorch 卷积操作

分布式架构系统拆分原则、需求、微服务拆分步骤

Section 27 remote access virtual private network workflow and experimental demonstration

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

pytorch中常用数据集的使用方法

2022年G1工业锅炉司炉特种作业证考试题库及在线模拟考试
![AssertionError assert I.ndim == 4 and I.shape[1] == 3](/img/b1/0109bb0f893eb4c8915df36c100907.png)
AssertionError assert I.ndim == 4 and I.shape[1] == 3
随机推荐
Dual contractual learning: text classification via label aware data augmentation reading notes
LeetCode_53(最大子数组和)
Difference between cookie and session
分布式锁的实现
2022 t elevator repair question bank and simulation test
OdeInt與GPU
神经网络-卷积层
C#读写应用程序配置文件App.exe.config,并在界面上显示
Shell之分析服务器日志命令集锦
科研狗可能需要的一些工具
STM32 光敏电阻传感器&两路AD采集
RDF query language SPARQL
Leecode question brushing record 1332 delete palindrome subsequence
2022-02-15 (399. Division evaluation)
Advanced application of ES6 modular and asynchronous programming
RuntimeError: “max_pool2d“ not implemented for ‘Long‘
Pytorch(四) —— 可视化工具 Visdom
One click shell to automatically deploy any version of redis
神经网络的基本骨架-nn.Moudle的使用
OdeInt与GPU