Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-332

Quantization Step Size

Problem

Compute the asymmetric quantization step size: (max(values) - min(values)) / (2^bits - 1). A constant list gives 0.0.

The signature is quantization_step_size(values, bits=8).

Hint

The step is the distance between adjacent representable levels.

Test cases

case 1
in: [[0,1],8]
expected: 0.00392156862745098
case 2
in: [[-1,1],8]
expected: 0.00784313725490196
case 3
in: [[5],4]
expected: 0
case 4
in: [[-2,3],16]
expected: 0.00007629510948348211
Starter codePython
def quantization_step_size(values, bits=8):
    # Your code here
    pass

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