Skip to content
DeepForgeby svx
All problems

Goal Image Embedding

Problem

Downsample a flattened goal image by average pooling.

Return one mean per non-overlapping block of the requested pool size. If pool is not positive or does not divide the length evenly, return [].

Hint

Pooling compresses the goal image into an embedding cheap enough to compare online.

Test cases

case 1
in: [[1,3,5,7],2]
expected: [2,6]
case 2
in: [[1,2,3],1]
expected: [1,2,3]
case 3
in: [[1,2,3],2]
expected: []
case 4
in: [[],2]
expected: []
Starter codePython
def goal_image_embedding(pixels, pool):
    # Your code here
    pass

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