nn.AvgPool2d实现nn.AdaptiveAvgPool2d

import torch
# 数据
x = torch.randn([1,3,4,4])
print(x.shape)

# nn.AdaptiveAvgPool2d结果
gap = nn.AdaptiveAvgPool2d(1)
print(gap(x))

# nn.AvgPool2d结果,参考resnest代码
gap2 = nn.AvgPool2d(kernel_size=(x.size(2),x.size(3)))
                           #ceil_mode=False)
print(gap2(x))

你可能感兴趣的:(#,深度学习框架,python,pytorch)