Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-237

Feature Map Bilinear Resize

Problem

Bilinearly resize a 2D feature map to out_h x out_w.

Map output index i to source coordinate i * (H - 1) / (out_h - 1) (0 when the output size is 1) and interpolate with coordinates clamped to the feature bounds. Round to 4 decimal places.

Test cases

case 1
in: [[[1,2],[3,4]],4,4]
expected: [[1,1.3333,1.6667,2],[1.6667,2,2.3333,2.6667],[2.3333,2.6667,3,3.3333],[3,3.3333,3.6667,4]]
case 2
in: [[[1,2,3],[4,5,6],[7,8,9]],2,2]
expected: [[1,3],[7,9]]
case 3
in: [[[1,2],[3,4]],1,1]
expected: [[1]]
case 4
in: [[[1,2],[3,4]],2,4]
expected: [[1,1.3333,1.6667,2],[3,3.3333,3.6667,4]]
Starter codePython
def bilinear_resize(feature, out_h, out_w):
    # Your code here
    pass

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