25
$\begingroup$

Could you implement a simple neural network on a microprocessor such as the Arduino Uno to be used in machine learning?

$\endgroup$
9
  • 3
    $\begingroup$ Out of curiosity, why would you want to? $\endgroup$ Commented Nov 28, 2012 at 23:24
  • 1
    $\begingroup$ I'm not an expert in this area, but last I heard, the training of the NN was done in simulation, and the NN was implemented on a chassis, and probably one with a higher-level controller than the Arduino. $\endgroup$ Commented Nov 28, 2012 at 23:30
  • 2
    $\begingroup$ Well, you don't have to link it, you just train the NN in simulation, then extract the topology of the NN, including edge weights and node links. Then you program the NN (it's just an equation you have to solve). I think it sounds like a little more research is needed before you take on this project. $\endgroup$ Commented Nov 28, 2012 at 23:35
  • 1
    $\begingroup$ It's probably worth mentioning I'm 16 and this is my electronics major work for high school. $\endgroup$
    – Jordan
    Commented Nov 28, 2012 at 23:37
  • 1
    $\begingroup$ In that case, I presume that you're going above and beyond the call of duty in attempting to implement this? $\endgroup$
    – Joe Baker
    Commented Nov 29, 2012 at 5:14

5 Answers 5

11
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\begingroup$ I 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. $\endgroup$
    – fgb
    Commented Nov 28, 2012 at 23:43
24
$\begingroup$

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.

$\endgroup$
6
$\begingroup$

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.

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

There are now multiple frameworks that support neural network inference on microcontroller devices. Examples of open-source projects include:

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.