This is a neural network example built from scratch which is solving XOR
Net Scheme is: 2 input nodes (i1, i2), 2 hidden nodes (h1, h2), 1 output node (o1)
Bias is applied at each level, activation function - sigmoid.
Ramda is lib very similar to lodash, but the one I love. This lib is not used in network itself, it's only a helper:
var R = require('ramda');
void 0; //to not bloat the output
In order to get reproducible random we're using seed-random lib instead of Math.random:
And... It's working. If we will place `x > .5 ? 1 : 0`, it will definitely work properly, but even for now it is working.
We achieved to make our code to actually discover an algorhytm which is not familiar to it just by giving him examples.
Loading…
1 comment
posted 6 years ago by alskenobi
I really apreciate your code, thanks so much.
It really open my mind, I was doing a lot of things wrong.
But I'm facing some problems:
- I'm not using seed,
sometimes the code run and give the correct answers, but sometimes not.
Even forcing a loop to stop when the results are < 0.2
Do you have any suggestion?