Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-176

Hierarchical Feature Sizes

Problem

Compute feature map sizes through a backbone with the given strides.

Starting from (h, w), divide both dimensions by each stride using ceiling division ((n + s - 1) // s) in order, and return the list of [h, w] sizes per stage.

Hint

Ceiling division keeps odd sizes from collapsing too fast.

Test cases

case 1
in: [224,224,[4,2,2]]
expected: [[56,56],[28,28],[14,14]]
case 2
in: [32,32,[2,2,2,2]]
expected: [[16,16],[8,8],[4,4],[2,2]]
case 3
in: [224,224,[1]]
expected: [[224,224]]
Starter codePython
def feature_sizes(h, w, strides):
    # Your code here
    pass

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