Evaluating the accuracy of the quantized model on the test dataset
After training the model using TensorFlow, we are ready to make it suitable for microcontroller deployment.
In this recipe, we will quantize the trained model to 8-bit using the TensorFlow Lite converter tool and then assess its accuracy with the test dataset. After evaluating the model’s accuracy, we will use the xxd
tool to convert the TensorFlow Lite model to a C-byte array, preparing it for deployment on the microcontroller.
Getting ready
Quantization is a pivotal technique in the ML world on microcontrollers because it makes the model storage-efficient and boosts its latency inference.
The quantization adopted in this book involves converting 32-bit floating-point numbers to 8-bit integers. While this technique offers a model reduction of four times and a latency improvement, we could lose accuracy because of the reduced numerical precision. For this reason, it is paramount to evaluate...