Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-057

Model Size (MB)

Problem

Estimate the storage size of a model in mebibytes: num_params * bytes_per_param / (1024 * 1024).

The signature is model_size_mb(num_params, bytes_per_param).

Hint

Float32 uses 4 bytes and float16 uses 2 bytes per parameter.

Test cases

case 1
in: [1000000,4]
expected: 3.8146972656
case 2
in: [7000000000,2]
expected: 13351.4404296875
case 3
in: [1024,4]
expected: 0.00390625
case 4
in: [1,1]
expected: 9.537e-7
Starter codePython
def model_size_mb(num_params, bytes_per_param):
    # Your code here
    pass

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