An artificial neural network library for Arduino
Neuroduino is a two-layer perceptron network with a simplified API suitable for Arduino projects that need to flexibly associate an input pattern with an output pattern. See Neuroduino Example for a functioning example. This library was developed in 2010 at the Interactive Telecommunications Program for my thesis, The Dawn Chorus.
Example uses:
- Simple clustering and classification (but not XOR until backpropagation is finished!)
- 'Natural' language emergence (as in my thesis)
- Conceivably, simple stabilization of servos or motors
Pull requests for bug fixes, improvements, documentation, etc are absolutely welcome!
Neuroduino myNet;
int netArray[NUM_LAYERS] = {8,8};
int inputArray[] = {1, -1, 1, -1, -1, 1, -1, 1}; // The input to be trained to
int trainArray[] = {-1, 1, -1, -1, 1, -1, 1, -1}; // What you want the network to output when it gets the inputArray
myNet = Neuroduino(netArray, NUM_LAYERS, ETA, THETA, DEBUG);NUM_LAYERSis currently fixed to 2. If anyone wants to finish implementing backpropagation, I would welcome your pull requests!ETAis the learning rate: the amount each value changes on each iteration. Making this larger makes learning much faster, but can result in oscillations. Making it smaller does the opposite. 0.1 by default.THETAis the activation threshold. This is 0.0 by default.DEBUGturns on extra debugging output. False by default.
srand(analogRead(0)); (or use a fixed integer for reproducible results)
myNet.randomizeWeights();printArray(myNet.simulate(inputArray), netArray[1]);
Eventually, the network should output trainArray when it gets inputArray. Yay! Why go through all this trouble? The association between input and output is flexible, so small 'imperfections' in the input should still produce the desired output.