Could you implement a simple neural network on a microprocessor such as the Arduino Uno to be used in machine learning?
5 Answers
It's certainly possible to implement this on an Arduino. Here are 3 such Arduino libraries that implement neural networks:
The complexity of the network that the Arduino can handle is a separate question, especially when it comes to training -- tens of thousands of iterations on training data. Training on a fast machine and then copying the neuron weights to the Arduino will be a smarter way to develop your implementation.
- 11,013
- 2
- 23
- 65
Could you train a neural network on a microcontroller? Maybe, but please don't try. Could you use a NN for classification, etc on a microcontroller? Sure, as long as you can calculate the result of propagating the node and edge values and handle the multiplications.
- 5,362
- 20
- 40
-
1I concur. Assuming you can get a neural network of the required complexity to train on the Arduino, you'll still be up for an insane amount of training time. Off-board training of the NN is the logical way to go. – fgb Nov 28 '12 at 23:43
Yes. If you only run it in feed-forward mode and do your training off-line somewhere else:
I programmed a 3-layer (5-5-2) feedforward ANN on an Arduino UNO. It ran on a mobile robot. Whenever the robot would hit something, it would re-train the network. The feedforward portion of the net ran in real-time; while the back-propagation training took on the order of ~5 to 20 seconds. I suppose you could trim the size of the network as well as the play with the parameters to make it run a bit faster, but if you plan on doing backpropagation on an Arduino, I think it would be too slow.
Some thoughts to speed things up include:
- Use fixed vs floating point (for MCU's w/o an FPU)
- Use an MCU that has a FPU
- Use a simpler activation function (ie. $\tanh$) instead of Sigmoid
- Have the training phase occur offline on a PC
Here's a quick write-up I did of the network.
Yes indeed, it's possible to embed neural network in microcontrollers. There are many such examples of this in the scientific literature but I can cite a striking example of what can be done with a very simple MCU if you're smart enough. In Evolutionary Bits'n'Spikes, the authors describe the implementation of a real time spiking neural network AND a genetic algorithm to train it, in order to control a differential wheel robot. The whole code runs in a tiny PIC16F628 4MHz MCU embedded on the 1-cubic-inch Alice robot.
- 308
- 2
- 9
There are now multiple frameworks that support neural network inference on microcontroller devices. Examples of open-source projects include:
- 111
- 2
As mentioned by you, i looked up these neural network libraries, such as ArduinoANN, but these are giving some error regarding less ram while verifying on Energia for MSP430G2553 kits, which i am using. So, i wanted to ask if there are some other neural network code for my kit,coz i am new in AI too :P, or if i am doing any mistake while compiling the code. – aditya malhotra Mar 29 '16 at 10:01