Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-306

ViT Patch Grid

Problem

Compute the patch grid a Vision Transformer sees for an image.

Return [rows, cols] where rows = h // patch and cols = w // patch. Both image dimensions are divisible by patch.

Test cases

case 1
in: [224,224,16]
expected: [14,14]
case 2
in: [224,224,32]
expected: [7,7]
case 3
in: [64,96,16]
expected: [4,6]
case 4
in: [32,32,8]
expected: [4,4]
Starter codePython
def patch_grid(h, w, patch):
    # Your code here
    pass

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