Click4Ai

340.

Hard

Feature Pyramid Network

**Problem Statement:** Implement a Feature Pyramid Network (FPN) to extract features from a feature map at multiple scales. FPN is a popular architecture used in object detection tasks to extract features from a feature map at multiple scales.

**Example:** If we have a feature map with size 7x7, we want to extract features from it at scales 2x2, 3x3, 4x4, 5x5, and 6x6.

**Constraints:** The FPN should be able to extract features from a feature map at multiple scales, and the features should be downsampled by a factor of 2 for each scale.

Test Cases

Test Case 1
Input: {"feature_map": [[1, 2, 3], [4, 5, 6], [7, 8, 9]], "scales": [2, 3, 4, 5, 6]}
Expected: [[[[1. 2. 3.] [1. 2. 3.]]], [[[4. 5. 6.] [4. 5. 6.]]], [[[7. 8. 9.] [7. 8. 9.]]], [[[1. 2. 3.] [1. 2. 3.]], [[4. 5. 6.] [4. 5. 6.]]], [[[7. 8. 9.] [7. 8. 9.]]]]
Test Case 2
Input: {"feature_map": [[1, 2, 3], [4, 5, 6], [7, 8, 9]], "scales": [2, 3, 4, 5, 6]}
Expected: [[[[1. 2. 3.] [1. 2. 3.]]], [[[4. 5. 6.] [4. 5. 6.]]], [[[7. 8. 9.] [7. 8. 9.]]], [[[1. 2. 3.] [1. 2. 3.]], [[4. 5. 6.] [4. 5. 6.]]], [[[7. 8. 9.] [7. 8. 9.]]]]
+ 3 hidden test cases