当前位置:网站首页>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 .
边栏推荐
- TCP server communication flow
- 神经网络-最大池化的使用
- LM小型可编程控制器软件(基于CoDeSys)笔记十九:报错does not match the profile of the target
- How to do the performance pressure test of "Health Code"
- 手动实现一个简单的栈
- Talk about testdeploy
- VIM简易使用教程
- RuntimeError: “max_pool2d“ not implemented for ‘Long‘
- 2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis
- Difference between cookie and session
猜你喜欢

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

slf4j 简单实现

Introduction to JVM stack and heap

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

Pytorch(二) —— 激活函数、损失函数及其梯度

CF1638E. Colorful operations Kodori tree + differential tree array

Section 27 remote access virtual private network workflow and experimental demonstration

PR 2021 quick start tutorial, learn about the and functions of the timeline panel

Dual Contrastive Learning: Text Classification via Label-Aware Data Augmentation 阅读笔记

【硬十宝典】——1.【基础知识】电源的分类
随机推荐
Kodori tree board
2022 question bank and answers for safety production management personnel of hazardous chemical production units
Shell之分析服务器日志命令集锦
Daily question - line 10
分布式全局唯一ID解决方案详解
Introduction to JVM stack and heap
pytorch神经网络搭建 模板
[FTP] common FTP commands, updating continuously
RuntimeError: mean(): input dtype should be either floating point or complex dtypes.Got Long instead
pytorch中常用数据集的使用方法
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
Why is Internet thinking not suitable for AI products?
2022.2.7-2.13 AI industry weekly (issue 84): family responsibilities
VIM简易使用教程
Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com. and
Quelques outils dont les chiens scientifiques pourraient avoir besoin
Shell analysis server log command collection
【硬十宝典】——2.【基础知识】开关电源各种拓扑结构的特点
One click shell to automatically deploy any version of redis
无器械健身