Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-312

Patch Merging Output Size

Problem

Compute the output shape of a Swin patch-merging layer.

Each 2 x 2 block of an h x w x channels map is concatenated into 4 * channels features at half the spatial resolution, using ceiling division for odd sizes. Return [out_h, out_w, out_channels].

Test cases

case 1
in: [224,224,96]
expected: [112,112,384]
case 2
in: [7,5,1]
expected: [4,3,4]
case 3
in: [1,1,32]
expected: [1,1,128]
case 4
in: [56,56,96]
expected: [28,28,384]
Starter codePython
def patch_merge_output(h, w, channels):
    # Your code here
    pass

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