pytorch torch.nn.AdaptiveAvgPool2d()自适应平均池化函数详解
Python  /  管理员 发布于 5年前   687
如题:只需要给定输出特征图的大小就好,其中通道数前后不发生变化。具体如下:
AdaptiveAvgPool2d
CLASStorch.nn.AdaptiveAvgPool2d(output_size)[SOURCE]
Applies a 2D adaptive average pooling over an input signal composed of several input planes.
The output is of size H x W, for any input size. The number of output features is equal to the number of input planes.
Parameters
output_size C 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.
Examples
>>> # target output size of 5x7>>> m = nn.AdaptiveAvgPool2d((5,7))>>> input = torch.randn(1, 64, 8, 9)>>> output = m(input)>>> # target output size of 7x7 (square)>>> m = nn.AdaptiveAvgPool2d(7)>>> input = torch.randn(1, 64, 10, 9)>>> output = m(input)>>> # target output size of 10x7>>> m = nn.AdaptiveMaxPool2d((None, 7))>>> input = torch.randn(1, 64, 10, 9)>>> output = m(input)
>>> input = torch.randn(1, 3, 3, 3)>>> inputtensor([[[[ 0.6574, 1.5219, -1.3590], [-0.1561, 2.7337, -1.8701], [-0.8572, 1.0238, -1.9784]], [[ 0.4284, 1.4862, 0.3352], [-0.7796, -0.8020, -0.1243], [-1.2461, -1.7069, 0.1517]], [[ 1.4593, -0.1287, 0.5369], [ 0.6562, 0.0616, 0.2611], [-1.0301, 0.4097, -1.9269]]]])>>> m = nn.AdaptiveAvgPool2d((2, 2))>>> output = m(input)>>> outputtensor([[[[ 1.1892, 0.2566], [ 0.6860, -0.0227]], [[ 0.0833, 0.2238], [-1.1337, -0.6204]], [[ 0.5121, 0.1827], [ 0.0243, -0.2986]]]])>>> 0.6574+1.5219+2.7337-0.15614.7569>>> 4.7569/41.189225>>>
以上这篇pytorch torch.nn.AdaptiveAvgPool2d()自适应平均池化函数详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号