interpreter.get_input_details() 中的“量化”是什么意思?

mrg*_*oom 5 python quantization tensorflow tensorflow-lite

使用 tflite 并获取解释器的属性,例如:

print(interpreter.get_input_details())

[{'name': 'input_1_1', 'index': 47, 'shape': array([  1, 128, 128,   3], dtype=int32), 'dtype': <class 'numpy.uint8'>, 'quantization': (0.003921568859368563, 0)}]
Run Code Online (Sandbox Code Playgroud)

什么'quantization': (0.003921568859368563, 0)意思?

小智 5

这意味着量化参数值:输入张量的比例和零点。

这是使用公式将量化的 uint8 数 q 转换为浮点数 f 所必需的:

f = (q - zero_point) * scale
Run Code Online (Sandbox Code Playgroud)