Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-266

Lottery Ticket Mask Ratio

Problem

Compute the fraction of weights that a magnitude pruning mask removes.

Return the proportion of weights whose absolute value is strictly below threshold, rounded to 4 decimal places.

Test cases

case 1
in: [[0.1,-0.5,0.05,0.9],0.2]
expected: 0.5
case 2
in: [[0.1,-0.5,0.05,0.9],0.05]
expected: 0
case 3
in: [[0.1,-0.5,0.05,0.9],1]
expected: 1
Starter codePython
def mask_ratio(weights, threshold):
    # Your code here
    pass

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