Hi Giorgos.
Thanks for your work. It is very interesting and useful! I tried your library in an Arduino nano 33 iot and works fine and in my opinion fast. I tested your example of Simple XOR with 5000 iterations.
But I have a question: how is possible to use the weights calculated in 'Void Status' inside of 'Void Loop' ? It is normal that weights has been calculated one time in Void Status. However, how I can use it in Void Loop? or I should create an Algorithm like W1×X1 + W2×X2 +... +Wn×Xn? Is there a way or function to get the outputs every time that change the input? Thanks!
josepramon:
Hi Giorgos.
Hi @josepramon
josepramon:
Thanks for your work. It is very interesting and useful!
Thank you for your interest and for your appreciation, means a lot to me <3 (:
(and i am sorry for my late response time ..)
josepramon:
I tried your library in an Arduino nano 33 iot and works fine and in my opinion fast.
Nice (:
josepramon:
how is possible to use the weights calculated in 'Void Status' inside of 'Void Loop' ? ... Is there a way or function to get the outputs every time that change the input?
Yes it is possible, Here Is a Brief Example how:
#define NumberOf(arg) ((unsigned int) (sizeof (arg) / sizeof (arg [0]))) //calculates the amount of layers (in this case 3)
#include <NeuralNetwork.h>
NeuralNetwork *NN; // creates a pointer to -> an object of NeuralNetwork in the RAM
const unsigned int layers[] = {2,4,1}; //3 layers (1st)layer with 2 input neurons (2nd)layer with 4 hidden neurons and (3rd)layer with 1 output neuron
float *outputs; // 3rd layer's outputs (in this case output)
//Default Inputs [for Training only]
const float inputs[4][2] = {
{0, 0}, //0
{0, 1}, //1
{1, 0}, //1
{1, 1} //0
};
const float expectedOutput[4][1] = {{0},{1},{1},{0}}; // values that we were expecting to get from the 3rd/(output)layer of Neural-network, in other words something like a feedback to the Neural-network.
void setup(){
Serial.begin(9600);
NN = new NeuralNetwork(layers,NumberOf(layers)); //Initialization of NeuralNetwork object
//Trains the NeuralNetwork for 3000 epochs = Training loops
for(int i=0; i < 3000; i++) // epochs = Training loops
{
for (int j = 0; j < NumberOf(inputs); j++)
{
NN->FeedForward(inputs[j]); // Feeds-Forward the inputs to the first layer of the NN and Gets the output.
NN->BackProp(expectedOutput[j]); // Tells to the NN if the output was right/the-expectedOutput and then, teaches it.
}
}
NN->print(); // prints the weights and biases of each layer
}
float INPUT_[1][2]; // Dynamic/Changable Input variable
void loop() {
//As a brief example, here you could have a live input from two buttons/switches (or a feed from a sensor if it where a different NN)
INPUT_[0][0] = 0; // ... lets say input from the 1st button/Switch?
INPUT_[0][1] = 1; // ... lets say input from the 2nd button/Switch?
outputs = NN->FeedForward(INPUT_[0]); // Feeds-Forward the Dynamic INPUT_[] to the first layer of the NN and Gets the output
Serial.println(outputs[0], 7); // prints the first 7 digits after the comma.
delay(1000);
}
Truth is that i should have more examples in my library...
PS. for everyone here, i am thinking of making some upgrades in the next months...
Hi Giorgos!
Thanks for your help. Your library is fantastic!
JR
There's also this, with quite a bit of explanation:
Karma+ Giovanni!
just released a new version a momment ago with many intresting features and with an example that you might be amazed
Spoider allert: "Image recognition"
i am going afk for today, see you tomorrow people <3
Simple Floor Cleaner Robot which is not only simple to make but costs a small fraction of such commercial products. The new Arduino Vacuum Cleaner is compact and more practical. On top of that, the robot has ultrasonic sensors and an IR proximity sensor. The ultrasonic sensor allows the robot to avoid obstacles so that it can move freely until the room is properly cleaned and the proximity sensor helps it to avoid falling from stairs.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.