For neuroevolution simulations. Works best with small models & large population size.
js
const populationSize = 1000;
let newGeneration = [];
for (let i = 0; i < populationSize; i++) {
// parentNN would be the best nn from past generation.
const childNN = parentNN;
childNN.mutateRandom(0.01, 0.65);
newGeneration.push(childNN);
}
Standalone function
Convert a Neural Network to a JS function that can output predictions without the library.
js
let strfunc = nn.toFunction();
console.log(strfunc);