## 3 TinyML Implemenatation
### Implementation Methodology
\]  
The following statement allows one to optimize the tflite file, as well as the quantization of the model already trained and converted to a tflite file:  
\[\mathit{converter.optimizations}=[tf\_lite.Optimize.DEFAULT\_TL]\]  
The previous instructions allow the quantization process in this compression step. Quantization is one of the main methods to reduce model size. It consists of converting the weights and activations of the floating precision (32-bit) model to lower precision values, typically 8-bit integers (\(uint8\)). This process considerably reduces the space needed to store the model weights and makes it ready for the third step of the compression process: converting from a tflite file to a cc file. An important aspect when creating a TinyML application is, as mentioned, the memory size that the trained model file will require, specifically in the RAM of the embedded system. As seen in Table 13, the tflite file has a size of less than 5000 KB; with this size, the model can be executed on a conventional computer or even on high-performance embedded systems  
Figure 16: Code snippet for obtaining the.cc file in Colab. Figure 15: Code snippet in Python used to obtain the accuracy and loss when training and evaluating the model on the computer with the model trained in _tflite_ file. such as the Raspberry Pi 4 or 5, and other equivalent embedded systems with RAM sizes greater than 10 MB. ESP32, Pi Pico, and Arduino Nano 33 BLE have a RAM bigger than 200 KB, while the CC extension model has a size of 5.2 KB. Running it out without quantization is possible in the third step of the compression process, as in the conversion step from H5 to tflite. Thus, it enables the use of the resulting model and its files in the implementation of the DNN in the selected embedded systems without having the problem of loss of accuracy in data prediction with the DNN due to a quantization process; the statements for this compression step are shown in Figure 16. However, under another scenario, which considers a larger dataset that generates data that, due to their type, use more memory space, and with a denser DNN architecture and other training hyperparameters, there is a possibility that the file size of the trained model is not supported into RAM of an embedded system that executes the DNN. Therefore, data quantization will have to be used after training in the file compression stage, and an analysis of the possible loss of accuracy with the model obtained will have to be performed. **Programming, deploying, and testing the trained model on the embedded system**. The hardware feature that is key for a Tiny embedded system to deploy ML models is mainly the RAM size, which supports and allocates the compressed training model, i.e., the cc file. It is a fact that the RAM size for the three embedded systems is smaller than 520 KB; this becomes a limitation to implementing TinyML with the file of the tflite model resulting from the training since, in some cases, the file size is up to 4000 KB. In contrast, the compressed file size in our experiment is 5.2 KB, as shown in Figure 16. Thus, it is important to show the relevant hardware features of the three embedded systems tested in our demonstrative implementation. It should be noted that carrying out a training process with a larger dataset, with a greater amount of data and characteristics, and with more demanding training parameters and hyperparameters will generate the final result of the training as a file to which it must be assigned a larger space in RAM than other small ones, to achieve its execution. However, it is correct to assume that training with a more complete dataset, DNN architecture with a greater number of layers and neurons, as well as more demanding training parameters and hyperparameters, will generate trained models with a higher degree of accuracy in the prediction.