nn4mp logo

nn4mp

Free

Deploy neural networks on microcontrollers for online inference

FreeFree tier
Type
Open Source
Company
Correll Lab, University of Colorado Boulder

About nn4mp

nn4mc (Neural Networks for Microcontrollers) is an open-source library from the Correll Lab at the University of Colorado Boulder that converts neural network models trained offline in Keras, TensorFlow, or other frameworks into C code for deployment on microcontrollers. It enables online predictions (regression or classification) on resource-constrained devices such as ESP32, Arduino, and any system running FreeRTOS. The library reads model parameters from an HDF5 file and generates portable C code, allowing embedded systems to perform real-time inference. nn4mc was presented at the International Symposium of Robotics Research (ISRR 2019) and supports cross-platform development with Linux setup scripts.

Key Features

Converts Keras/TensorFlow neural network models to C code for microcontrollers
Generates C code from HDF5 files containing trained model parameters
Supports ESP32, Arduino, and any FreeRTOS-compatible microcontroller
Enables online predictions (regression and classification) on embedded devices
Generalization of the ESP32 neural network approach by Dana Hughes
Includes Linux setup scripts, documentation, tutorials, and examples

Pros & Cons

Pros
  • Enables neural network inference on resource-constrained microcontrollers
  • Compatible with widely-used deep learning frameworks (Keras, TensorFlow) and hardware platforms (ESP32, Arduino, FreeRTOS)
  • Open source with MIT license, free to use and modify
  • Backed by academic research and citation support for scholarly use
Cons
  • Primarily supports feedforward neural networks; advanced architectures (CNN, RNN) may require additional conversion steps
  • Requires offline training on a powerful computer and parameter export to HDF5 format
  • Limited to microcontrollers that support C code; not for general-purpose desktop deployment
  • Community support via Stack Overflow and email; no dedicated commercial support

Best For

Deploying machine learning models on low-power microcontrollers for edge AIOnline estimation and classification on embedded systems (e.g., robot autonomy, sensor data processing)Running real-time neural network inference on ESP32 or Arduino without cloud connectivity

FAQ

What microcontrollers are supported?
nn4mc works with any microcontroller that supports C code, including ESP32, Arduino systems, and any platform running FreeRTOS.
How do I use a model trained in TensorFlow with nn4mc?
Train your model in Keras/TensorFlow, save the model parameters to an HDF5 file, then use the h5_nn4mc tool with the --source flag pointing to the HDF5 file to generate C code for the microcontroller.
Is nn4mc free and open source?
Yes, nn4mc is an open-source library hosted on GitHub under the MIT License, and it is free to use, modify, and distribute.