当前位置:网站首页>【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 )
边栏推荐
- It is designed with high bandwidth, which is almost processed into an open circuit?
- 安装Oracle EE
- 足球篮球体育比赛比分直播平台源码/app开发建设项目
- Why is the Ltd independent station a Web3.0 website!
- Imitation of Baidu search results top navigation bar effect
- 2.4 激活函数
- How to effectively align team cognition
- How to manage fixed assets efficiently in one stop?
- Leetcode daily question brushing record --540 A single element in an ordered array
- Insert mathematical formula in MD document and mathematical formula in typora
猜你喜欢

Jetson Nano 安装TensorFlow GPU及问题解决

2.2 【pytorch】torchvision.transforms

Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month

nacos簡易實現負載均衡

I use flask to write the website "one"

中小企业固定资产管理办法哪种好?

Dynamic proxy

钓鱼识别app

如何解决固定资产管理和盘点的难题?

What are the differences between the architecture a, R and m of arm V7, and in which fields are they applied?
随机推荐
I use flask to write the website "one"
Bird recognition app
LogBack
JCL and slf4j
Shell script echo command escape character
Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
MySQL optimization
2.4 激活函数
Shell脚本-for循环和for int循环
VSYNC+三重缓存机制+Choreographer
jeecg 重启报40001
Ape anthropology topic 20 (the topic will be updated from time to time)
Shell脚本-while循环详解
Record a redis timeout
集团公司固定资产管理的痛点和解决方案
Public network cluster intercom +gps visual tracking | help the logistics industry with intelligent management and scheduling
Nacos - 配置管理
Redis源码学习(29),压缩列表学习,ziplist.c(二)
[MFC development (17)] advanced list control list control
Shell脚本-echo命令 转义符