> For the complete documentation index, see [llms.txt](https://ztlevi.gitbook.io/ml-101/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ztlevi.gitbook.io/ml-101/ml-fundamentals/quantization.md).

# Quantization

quantize: [code](https://github.com/ztlevi/ML_101/blob/master/codes/quantization/torch_quantize.py)

* Converts a float tensor to quantized tensor with given scale and zero point.
* Quantization(x, scale, zero\_point) = round(x/scale + zero\_point)

dequantize: [code](https://github.com/ztlevi/ML_101/blob/master/codes/quantization/torch_dequantize.py)

* Mapping the quantized tensor back to the original scale and pivot

## Reference

* <https://www.h-schmidt.net/FloatConverter/IEEE754.html>
