All problems
Anchor Grid Generation
Problem
Generate anchor boxes for every cell of a feature map.
For cell (i, j) the center is (j * stride + stride / 2, i * stride + stride / 2); emit one [cx, cy, w, h] entry per anchor in the order given, iterating cells row-major. Round center coordinates to 4 decimal places.
Test cases
case 1
in: [2,2,8,[[16,16],[32,32]]]
expected: [[4,4,16,16],[4,4,32,32],[12,4,16,16],[12,4,32,32],[4,12,16,16],[4,12,32,32],[12,12,16,16],[12,12,32,32]]
case 2
in: [1,1,16,[[10,20]]]
expected: [[8,8,10,20]]
case 3
in: [1,2,4,[[8,8]]]
expected: [[2,2,8,8],[6,2,8,8]]
Starter codePython
def anchor_grid(feature_h, feature_w, stride, anchors):
# Your code here
pass3 test cases · run your code against them in the editor