Premium problem67. 2x2 Max Pooling

Easy Locked

x is (B, C, H, W). Apply max pooling with kernel size 2 and stride 2, halving both spatial dimensions.

Input

tensor([[[[ 0.,  1.,  2.,  3.],
          [ 4.,  5.,  6.,  7.],
          [ 8.,  9., 10., 11.],
          [12., 13., 14., 15.]],

         [[16., 17., 18., 19.],
          [20., 21., 22., 23.],
          [24., 25., 26., 27.],
          [28., 29., 30., 31.]]]])

Output

tensor([[[[ 5.,  7.],
          [13., 15.]],

         [[21., 23.],
          [29., 31.]]]])

Premium problem

This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.

Implement solve(...)