当前位置:网站首页>【pytorch】nn. AdaptiveMaxPool2d
【pytorch】nn. AdaptiveMaxPool2d
2022-07-01 09:08:00 【Enzo tried to smash the computer】
output_size – the target output size of the image of the form H x W. Can be a tuple (H, W) or a single H for a square image H x H. H and W can be either a int, or None which means the size will be the same as that of the input.
return_indices – if True, will return the indices along with the outputs. Useful to pass to nn.MaxUnpool2d. Default: False
m = torch.nn.AdaptiveMaxPool2d((5, 7))
input = torch.randn(1, 64, 8, 9)
output = m(input)
print(output.shape) # torch.Size([1, 64, 5, 7])
# target output size of 7x7 (square)
m = nn.AdaptiveAvgPool2d(7)
input = torch.randn(1, 64, 10, 9)
print(m(input).shape) # [1, 64, 7, 7]
# target output size of 10x7
m = nn.AdaptiveAvgPool2d((None, 7))
input = torch.randn(1, 64, 10, 9) # [1, 64, 10, 7]
output = m(input)
print(output.shape)
import torch.nn as nn
import torch
input = torch.tensor([[[[2, 4, 8, 15],
[3, 6, 9, 19],
[7, 22, 5, 12],
[1, 66, 1, 77]]]], dtype=torch.float64)
m = nn.AdaptiveMaxPool2d((3, 3))
output = m(input)
print(input)
print(output)
# padding I made it up myself , Convenient observation
# tensor([[[[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
# [0.0, 2., 4., 8., 15., 0.0],
# [0.0, 3., 6., 9., 19., 0.0],
# [0.0, 7., 22., 5., 12., 0.0],
# [0.0, 1., 66., 1., 77., 0.0],
# [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]]], dtype=torch.float64)
# tensor([[[[ 6., 9., 19.],
# [22., 22., 19.],
# [66., 66., 77.]]]], dtype=torch.float64)
Global average pooling GAP(Global Average Pooling) The advantage is that :
Categories on Feature Map The connection between them is more intuitive ( Compared with the black box with full connection layer ),Feature Map It is also easier to convert into classification probability , Because in GAP No parameters need to be adjusted in , Therefore, the problem of over fitting is avoided .
GAP Summarizes spatial information , Therefore, it is more robust to the spatial transformation of input , Therefore, the following full connection layers in convolutional networks , Mostly with GAP Replace .
Global pooling occurs in Kreas There are corresponding layers in , Maximize the pool layer for the global (GlobalMaxPooling2D), But in Pytorch Although there is no corresponding pool layer in , But you can use Pytorch Adaptive pooling layer in (==AdaptiveMaxPool2d(1) perhaps AdaptiveMaxPool2d(1)== To achieve )
边栏推荐
- Bimianhongfu queren()
- 固定资产管理系统让企业动态掌握资产情况
- Principle and application of single chip microcomputer timer, serial communication and interrupt system
- Shell脚本-echo命令 转义符
- Shell script -while loop explanation
- It technology ebook collection
- 2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据
- Shell script case in and regular expressions
- Principles of Microcomputer - internal and external structure of microprocessor
- DataBinding源码分析
猜你喜欢

大型工厂设备管理痛点和解决方案

Phishing identification app

MySQL optimization

Vsync+ triple cache mechanism +choreographer

如何做好固定资产管理?易点易动提供智能化方案

nacos服务配置和持久化配置

集团公司固定资产管理的痛点和解决方案

Principle and application of single chip microcomputer timer, serial communication and interrupt system

VSYNC+三重缓存机制+Choreographer

3. Detailed explanation of Modbus communication protocol
随机推荐
集团公司固定资产管理的痛点和解决方案
AVL树的理解和实现
MySQL optimization
Jetson Nano 安装TensorFlow GPU及问题解决
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DS18B20温度传感器 +NodeJs本地服务+ MySQL数据库
如何高效拉齐团队认知
Shell script -read command: read data entered from the keyboard
Pain points and solutions of equipment management in large factories
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DHT11 +NodeJs本地服务+ MySQL数据库
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于物联网的GY906红外测温门禁刷卡系统
Shell script -while loop explanation
Jeecg restart alarm 40001
Redis source code learning (29), compressed list learning, ziplist C (II)
Class loading
Key points of NFT supervision and overseas policies
[ESP nanny level tutorial] crazy completion chapter - Case: gy906 infrared temperature measurement access card swiping system based on the Internet of things
Vsync+ triple cache mechanism +choreographer
Football and basketball game score live broadcast platform source code /app development and construction project
Installing Oracle EE
nacos簡易實現負載均衡