Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-390

MAE Masked Token Count

Problem

Count masked and visible tokens for masked autoencoders.

Mask mask_ratio of the num_patches tokens (round half up) and return [masked, visible] counts. The visible tokens are the complement.

Hint

Only the visible tokens pass through the encoder in MAE.

Test cases

case 1
in: [196,0.75]
expected: [147,49]
case 2
in: [196,0]
expected: [0,196]
case 3
in: [100,0.4]
expected: [40,60]
case 4
in: [0,0.5]
expected: [0,0]
Starter codePython
def mae_token_counts(num_patches, mask_ratio):
    # Your code here
    pass

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