Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-222

Adaptive Average Pool

Problem

Apply adaptive average pooling to a 2D feature map.

For output cell (oh, ow) pool the input rows [oh * H // out_h, (oh + 1) * H // out_h) and columns [ow * W // out_w, (ow + 1) * W // out_w), ensuring at least one element. Round each mean to 4 decimal places.

Test cases

case 1
in: [[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]],2,2]
expected: [[3.5,5.5],[11.5,13.5]]
case 2
in: [[[1,2,3],[4,5,6],[7,8,9]],2,2]
expected: [[1,2.5],[5.5,7]]
case 3
in: [[[1,2],[3,4]],1,2]
expected: [[2,3]]
Starter codePython
def adaptive_avg_pool(feature, out_h, out_w):
    # Your code here
    pass

3 test cases · run your code against them in the editor