/ neuralnets

Neural Nets on Arduino

Early versions of libdeep did support exporting trained neural nets as an Arduino compatible C sketch, but at some point in the last couple of years I changed that to just standard C (C99). At the time I wasn't doing anything with Arduinos and it didn't seem likely that I would be in the near future, but after leaving Manchester at the end of 2016 I switched back to doing more hardware projects and I expect to be doing further hardware stuff later this year.

So Arduino support has been added back into libdeep. The changes needed aren't very great. Instead of reading from stdin the exported Arduino sketch reads from the analog inputs (or digital if you prefer), and you can then hook up the output values to whatever you want. LED eyelashes, motors, buzzers, or whatever.

As far as I know this export feature, which has always been part of libdeep, is unique among the various open source deep learning systems out there. So potentially you can train a neural net in simulation using however much data you have available and then transfer the result to a very low power and inexpensive board. Some of the Arduino compatible boards cost less than £2 on ebay. The battery costs more than the board.

To export in Arduino format just include the word "sketch" or "arduino" within the export filename. So for example:

deeplearn_export(&learner, "sketch.c");

You may need to change the pin numbers on the inputs and add code to do something with the output values, but this should get you running with a neural net quite rapidly.

There are various examples available in a subdirectory which can be used as a guide to how to build and train a neural net with libdeep, and there's also a manpage which explains things in more detail.