# Real-time Neural Networks Implementation Proposal for Microcontrollers
## 5 Comparison with the State-of-the-Art  
The work [PERSON] et al. [29] shows two implementations of an MLP-BP with single and dual hidden layers and their respective execution times for a classification with the results shown in Table 7. In [21], the authors were able to embed a full MNIST-10 classification model using CNNs with under 2 KB of SRAM; the inference times were also in the order of 640 ms per input sample.  
It is important to note that the times measurements presented in Table 7 take only the inferencing time into account. The implementation for [PERSON] et al. [29] trained the model offline using MatLab. For the [PERSON] [21] paper, the training was also executed offline on a Jupyter Notebook running Tensorflow-Keras models and optimizations before porting the synaptic weights and kernels to the \(\mu\)C.  
It is possible to analyze this proposal, regarding how this system would behave if it had to support the same hyperparameters that some of these state-of-the-art applications have. The work presented by [PERSON] et al. [29] uses an MLP ANN with a single layer with 100 artificial neurons. This same work also presents another implementation with a two-layer MLP with 200 artificial neurons. Analyzing the \(t_{\text{FFM-1}}\), \(t_{\text{FFM-2}}\), \(t_{\text{BPM-1}}\), and \(t_{\text{BPM-2}}\) fitted curves from Table 5, we obtained four predictive equations that define how much time is required to process this MLP implementation.  
The equation expressed as  
\[t_{\text{FFM-1}}\left(H^{1}\right)=11.6\times H^{1}+20.52 \tag{16}\]  
shows us again that there is a linear relationship between inference time and hyperparameters for the proposal in this work, specifically artificial neurons. Evaluating Equation (16), with 100 units, a feedowarding time of 1.18 s is observed for the first layer.  
Taking into account the same amount of neurons for the equation characterized as  
\[t_{\text{FFM-2}}\left(H^{2}\right)=1.22\times H^{2}+2.49, \tag{17}\]  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Datasets** & \(H^{1}\) & \(t_{\text{FFM-1}}\) (ms) & \(t_{\text{FFM-2}}\) (ms) & \(t_{Total\text{-FFM-k}}\) \\ \hline
1 & 5 & 1.28 & 0.52 & 1.80 \\
2 & 5 & 1.28 & 0.52 & 1.80 \\
3 & 10 & 2.63 & 0.88 & 3.51 \\ \hline \hline \end{tabular}
\end{table}
Table 6: Execution times measured with Hardware-In-the-Loop (HIL) for the implementation proposal in the virtual carlike robot validation.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Reference** & **Model** & **Time (ms)** & **Memory (KB)** \\ \hline [PERSON] et al. [29] & MLP-1 & 17.35 & 14.73 \\ [PERSON] et al. [29] & MLP-2 & 9.17 & 13.53 \\ [PERSON] \& [PERSON] [21] & AvgPool2 \(\times\) 2 + CNN3 \(\times\) 3 + MaxPool + MLP & 684 & 8.46 \\ Proposal & MLP-2 & 69.88 * & 6.67 \\ \hline \hline \end{tabular}
\end{table}
Table 7: Artificial Neural Network (ANN) results for the state-of-the-art works.* Time of inference, not taking the EM-k and BPM-k modules time into account.  
124.49 ms of feedforwarding time for the second layer was achieved. This amounts to 1.30 s of total inferencing time with 100 neurons.  
If the embedded training is to be also considered with this amount of neurons, the time duration for this process increases to 1.44 s by evaluating the equation expressed as  
\[t_{\text{BPM-1}}\left(H^{2}\right)=1.41\times H^{2}+2.7. \tag{18}\]  
Furthermore, evaluating the equation  
\[t_{\text{BPM-2}}\left(H^{1}\right)=6.03\times H^{1}+10.94 \tag{19}\]  
for the second layer, considering two hidden layers for training, the time duration increases to 2.06 s. This analysis shows that the modular implementation of the MLP herein presented performs in compatible training and inference times.