Blog Home

Recognizing handwritten MNIST digits on an Arduino Uno using LogNNet

Arduino TeamMay 19th, 2021

The Arduino Uno is famous for its ease of use and compact size, yet its microcontroller, the ATmega328P, is quite small. The 328P contains a mere 32KB of flash storage for programs and 2KB of RAM, which has traditionally made it unsuitable for machine learning applications. However, a team at the Institute of Physics and Technology at Petrozavodsk State University was able to cram an algorithm that can recognize the handwritten digits within the MNIST dataset. Without getting too complicated, the Uno takes in an array of pixels that range in value from 0 to 255, or one byte. The entire 28 by 28 grid is then flattened to a single array of 784 elements that is passed into a reservoir that holds the weights for each pixel. As the model continues to get trained, these weights are gradually adjusted until the output matches the correct digit.

Input data is read from the serial port and stored within an array, where it is then used within the LogNNet library to compute the layer values. Once everything has been passed through the neural network the resulting digit is printed to the serial monitor. Overall, the neural network’s variables in RAM are quite space-efficient and account for just over a kilobyte. 

As seen below, the researchers were able to achieve an accuracy of 82% with an inferencing time of around seven seconds, which is quite impressive for such a small chip. To read more about how the LogNNet reservoir neural network operates, be sure to check out the team’s paper.

Image: Izotov et al.