All problems
Global Average Pooling
Problem
Compute global average pooling over an image.
Return the arithmetic mean of all pixel values as a float. You may assume the image is non-empty.
Test cases
case 1
in: [[[1,2],[3,4]]]
expected: 2.5
case 2
in: [[[5]]]
expected: 5
case 3
in: [[[1,1,1],[1,1,1]]]
expected: 1
case 4
in: [[[10,20],[30,40]]]
expected: 25
Starter codePython
def global_avg_pool(image):
# Your code here
pass4 test cases · run your code against them in the editor