pytorch学习笔记

nn.AdaptiveAvgPool2d

a = nn.AdaptiveAvgPool2d((5, 7))
output = a(input)
print('5x7:',output)
# 目标输出大小为 7x7(正方形)
m = nn.AdaptiveAvgPool2d(7)
output = m(input)
print('7x7:',output)

5x7: tensor([[[[ 0.3847,  0.6597,  0.0249,  0.3430,  0.2783, -0.3439, -1.1087],
          [-0.0574,  0.7386,  0.6476,  0.3687, -0.1651, -0.3378, -0.3508],
          [-0.3331,  0.3783,  0.4337, -0.2494, -0.6286, -0.0352,  0.0131],
          [-0.5599, -0.1819, -0.3177, -0.5623,  0.0833,  0.1311, -0.4833],
          [ 0.0169,  0.3534, -0.0434, -0.3368,  0.3731, -0.4099, -0.7534]]]])
7x7: tensor([[[[ 0.3847,  0.6597,  0.0249,  0.3430,  0.2783, -0.3439, -1.1087],
          [-0.0040,  0.5401,  0.3237,  0.6172,  0.1927, -0.4535, -0.6810],
          [-0.1919,  0.8235,  0.7367,  0.1908, -0.6345, -0.5306, -0.1679],
          [-0.3331,  0.3783,  0.4337, -0.2494, -0.6286, -0.0352,  0.0131],
          [-0.7913, -0.7301, -0.6630, -0.4539,  0.1089,  0.5917, -0.2622],
          [-0.5888, -0.0834, -0.2626, -0.6581,  0.3132,  0.1788, -0.5833],
          [ 0.0169,  0.3534, -0.0434, -0.3368,  0.3731, -0.4099, -0.7
534]]]])

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值