Tiny Machine Learning On The Attiny85

We tend to think that the lowest point of entry for machine learning  (ML) is on a Raspberry Pi, which it definitely is not. [EloquentArduino] has been pushing the limits to the low end of the scale, and managed to get a basic classification model running on the ATtiny85.

Using his experience of running ML models on an old Arduino Nano, he had created a generator that can export C code from a scikit-learn. He tried using this generator to compile a support-vector colour classifier for the ATtiny85, but ran into a problem with the Arduino ATtiny85 compiler not supporting a variadic function used by the generator. Fortunately he had already experimented with an alternative approach that uses a non-variadic function, so he was able to dust that off and get it working. The classifier accepts inputs from an RGB sensor to identify a set of objects by colour. The model ended up easily fitting into the capabilities of the diminutive ATtiny85, using only 41% of the available flash and 4% of the available ram.

It’s important to note what [EloquentArduino] isn’t doing here: running an artificial neural network. They’re just too inefficient in terms of memory and computation time to fit on an ATtiny. But neural nets aren’t the only game in town, and if your task is classifying something based on a few inputs, like reading a gesture from accelerometer data, or naming a color from a color sensor, the approach here will serve you well. We wonder if this wouldn’t be a good solution to the pesky problem of identifying bats by their calls.

We really like how approachable machine learning has become and if you’re keen to give ML a go, have a look at the rest of the EloquentArduino blog, it’s a small goldmine.

We’re getting more and more machine learning related hacks, like basic ML on an Arduino Uno, and Lego sortings using ML on a Raspberry Pi.

19 thoughts on “Tiny Machine Learning On The Attiny85

    1. It is true that if there are more than seven IF statements in a row marketing gets to call it Machine Learning.

      The every day use is to write software when you don’t know what the data or function is going to be.
      I’m involved in more projects that would recently have had many more programmers in. They’ve been replaced with a few data scientists and someone who knows how to order CPU cycles from AWS.
      For example: I worked on scraping data from legal forms, it was far cheaper to use machine learning than to have a few junior developers writing the functionally equivalent regular expressions.

      1. It would be interesting to read more about that ML scraping project, because I still have a hard time imagining all the ways that ML can be useful. Maybe something for a HaD article?

  1. I’m the author of the post cited.

    First of all, “Machine learning” results can’t always be achieved by “manual programming”, because you may not be able to grasp all the facets of your data, if you have a lot of data. Second, ML models can evolve in time without any programmer intervention.

    I think it could be more agreeable if you say “it seems Machine Learning is what we used to call statistics”.

      1. Never used PID in practice, just studied it at university and read some articles. I think the difference is 1) they can “learn” at most 3 parameters (P, I, D) and 2) they don’t learn a decision function, they learn how to follow a set point and are not stationary (the same input, at different times, produces different output). But I may be wrong.

Leave a Reply to ChrisCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.