SOLUTION FOR DIRECT IMPLEMENTATION OF RECURRENT NEURAL NETWORKS ON MICROCONTROLLERS

Authors

  • Nguyễn Văn Khanh
  • Thái Bảo Toàn
  • Trần Vỹ Khang
  • Trần Thành Luân
  • Nguyễn Văn Mướt
  • Nguyễn Chí Ngôn

Keywords

On-device training, Edge AI, TinyML, Recurrent neural network, Model quantization, Huấn luyện trực tiếp trên thiết bị, Trí tuệ nhân tạo biên, Học máy siêu nhẹ, Mạng nơ-ron hồi quy, Lượng tử hoá mô hình

DOI:

https://doi.org/10.34238/tnu-jst.15162

Abstract

Recurrent neural networks are highly effective for time series forecasting. However, few studies evaluate their direct deployment on microcontrollers. This study aims to analyze and integrate recurrent neural networks and their variants, including gated recurrent units and long short-term memorys, into resource-constrained microcontrollers. The core cells of recurrent neural networks are implemented in C/C++ and integrated into the NeuralLite library, which is designed for training neural networks on microcontrollers. A post-training quantization mechanism is also incorporated to optimize memory usage. The completed library, NeuralLite-v2, is employed to compute an approximation of the sine function on the ESP32-P4. The results demonstrate successful on-device training, and the quantization method reduces memory usage by approximately 66% while maintaining accuracy after quantization. The microcontroller-based model yields results comparable to the PyTorch implementation, with fast inference time, making it suitable for embedded and edge applications.

Downloads

Download data is not yet available.

References

S. A. R. Zaidi, A. M. Hayajneh, M. Hafeez, and Q. Z. Ahmed, "Unlocking Edge Intelligence Through Tiny Machine Learning (TinyML)," IEEE Access, vol. 10, pp. 100867-100877, 2022, doi: 10.1109/ACCESS.2022.3207200.

N. N. Alajlan and D. M. Ibrahim, "TinyML: Enabling of Inference Deep Learning Models on Ultra-Low-Power IoT Edge Devices for AI Applications," Micromachines, vol. 13, 2022, doi: 10.3390/mi13060851.

H.-c. Han and J. Siebert, "TinyML: A Systematic Review and Synthesis of Existing Research," 2022 International Conference on Artificial Intelligence in Information and Communication (ICAIIC), pp. 269-274, 2022, doi: 10.1109/ICAIIC54071.2022.9722636.

L. Capogrosso, F. Cunico, D. S. Cheng, F. Fummi, and M. Cristani, "A Machine Learning-Oriented Survey on Tiny Machine Learning," IEEE Access, vol. 12, pp. 23406-23426, 2023, doi: 10.1109/ACCESS.2024.3365349.

N. V. Schizas, A. Karras, C. N. Karras, and S. Sioutas, "TinyML for Ultra-Low Power AI and Large Scale IoT Deployments: A Systematic Review," Future Internet, vol. 14, 2022, Art. no. 363, doi: 10.3390/fi14120363.

V.-K. Nguyen, B.-T. Thai, V.-K. Tran, H. Pham, and C.-N. Nguyen, "Real-time anomaly detection in electric motor operation noise," IAES International Journal of Artificial Intelligence, vol. 13, no. 4, pp. 3814-3826, 2024, doi: 10.11591/ijai.v13.i4.pp3814-3826.

T.-L. Tran, B.-T. Thai, V.-K. Tran, X.-N. Nguyen-Thi, C.-N. Nguyen, and V.-K. Nguyen, "Real-time Assessment of ECG Classification based on Time-series Data and Other Types of Features," Journal of Engineering and Technological Sciences, vol. 57, no. 4, pp. 530-544, 2025, doi: 10.5614/j.eng.technol.sci.2025.57.4.8.

M. J. C. S. Reis and C. Serôdio, "Edge AI for Real-Time Anomaly Detection in Smart Homes," Future Internet, vol. 17, 2025, Art. no. 179, doi: 10.3390/fi17040179.

K. Venkateswarlu et al., "Edge AI in Sustainable Farming: Deep Learning-Driven IoT Framework to Safeguard Crops From Wildlife Threats," IEEE Access, vol. 12, pp. 77707-77723, 2024, doi: 10.1109/ACCESS.2024.3406585.

H. Cai, C. Gan, L. Zhu, and S. Han, "Tinytl: Reduce activations, not trainable parameters for efficient on-device learning," arXiv preprint arXiv:2007.11622, 2020, doi: arXiv:2007.11622.

B.-T. Thai, V.-K. Tran, H. Pham, C.-N. Nguyen, and V.-K. Nguyen, "On-device training of artificial intelligence models on microcontrollers," IAES International Journal of Artificial Intelligence, 2024, vol. 13, no. 3, pp. 2829-2839, 2024, doi: 10.11591/ijai.v13.i3.pp2829-2839.

Y. D. Kwon, R. Li, S. I. Venieris, J. Chauhan, N. D. Lane, and C. Mascolo, "TinyTrain: Resource-aware task-adaptive sparse training of DNNs at the data-scarce edge," arXiv preprint arXiv:2307.09988, 2023, doi: 10.5555/3692070.3693103.

E. Torti, M. Musci, F. Guareschi, F. Leporati, and M. Piastra, "Deep Recurrent Neural Networks for Edge Monitoring of Personal Risk and Warning Situations," Sci. Program., vol. 2019, pp. 9135196:1-9135196:10, 2019, doi: 10.1155/2019/9135196.

C. Gao, A. Rios-Navarro, X. Chen, T. Delbrück, and S.-C. Liu, "EdgeDRNN: Enabling Low-latency Recurrent Neural Network Edge Inference," in 2020 2nd IEEE International Conference on Artificial Intelligence Circuits and Systems (AICAS), pp. 41-45, 2020, doi: 10.1109/AICAS48895.2020.9074001.

P. J. Werbos, "Backpropagation Through Time: What It Does and How to Do It," Proc. IEEE, vol. 78, pp. 1550-1560, 1990, doi: 10.1109/5.58337.

S. Zhou et al., "LiDAR-PTQ: Post-Training Quantization for Point Cloud 3D Object Detection," ArXiv, vol. abs/2401.15865, 2024, doi: 10.48550/arXiv.2401.15865.

B. Jacob et al., "Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference," in 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2018, pp. 2704-2713.

R. Krishnamoorthi, "Quantizing deep convolutional networks for efficient inference: A whitepaper," ArXiv, vol. abs/1806.08342, 2018, doi: 10.48550/arXiv.1806.08342.

F. Cardinaux et al., "Iteratively Training Look-Up Tables for Network Quantization," IEEE Journal of Selected Topics in Signal Processing, vol. 14, pp. 860-870, 2018, doi: 10.1109/JSTSP.2020.3005030.

B.-T. Thai, V.-K. Tran, C.-N. Nguyen, and V.-K. Nguyen, "On-Device Training Based Anomaly Detection Platform," Journal of Soft Computing and Data Mining, vol. 6, no. 3, pp. 85-102, 2025, doi: 10.30880/jscdm.2025.06.03.007.

D. P. Kingma and J. Ba, "Adam: A method for stochastic optimization," arXiv preprint, 2014, doi: 10.48550/arXiv.1412.6980.

Y. Liu, Y. Gao, and W. Yin, "An improved analysis of stochastic gradient descent with momentum," Advances in Neural Information Processing Systems, vol. 33, pp. 18261-18271, 2020, doi: 10.48550/arXiv.2007.07989.

Published

2026-06-04

Issue

Section

INFORMATION AND COMMUNICATIONS TECHNOLOGY