-
Notifications
You must be signed in to change notification settings - Fork 280
Home
Neataptic is thé Javascript neural network solution. Not only does it allow you to create neural networks on-the-go, it also allows you to visualise your networks to understand what's really going on. An important aspect that neataptic introduces in comparison with its competitors is neuro-evolution. You can evolve neural networks through a process described in the NEAT paper.
This allows compability with all kinds of projects; training an XOR gate, controlling a robot or a image classifier.
This is an example of the creation and loop of a genetic neural network. The goal of this genetic algorithm is too create a population that will output a value that is as high as possible (=1
) when inputted 0
. Please note that this is just an example, and this problem is much easier to 'solve' by backpropagating.
/** The XOR training set */
var trainingSet = [
{ input: [0, 0], output: [0] },
{ input: [0, 1], output: [1] },
{ input: [1, 0], output: [1] },
{ input: [1, 1], output: [0] },
];
/** Set up the built-in genetic algorithm */
var neat = new Neat(2, 1, fitnessFunction, {
mutationAmount: 3,
mutationRate: 0.6,
equal: true
});
/** Fitness function, calculate the error */
function fitnessFunction(genome){
return -genome.test(trainingSet, Methods.Cost.MSE).error;
}
/** The main loop */
function loop(){
neat.evolve();
var fittest = neat.getFittest();
if(fittest.score < -0.03 && neat.generation < 500){
setTimeout(loop, 100);
}
};
Run it here!
If you want to know how to set up one of these algorithms yourself, feel free to take a look at the wiki pages! If you want to implement a genetic neural network algorithm, but don't know how, feel free to contact me at wagenaartje@protonmail.com!