wagenaartje / neataptic

:rocket: Blazing fast neuro-evolution & backpropagation for the browser and Node.js
https://wagenaartje.github.io/neataptic/
Other
1.19k stars 279 forks source link

Issue with multiple inputs and multiple outputs always returning NAN #158

Closed Cpt-Falcon closed 5 years ago

Cpt-Falcon commented 5 years ago

Hello, running a test node script to debug some other code i've written. Here is my script.

const neataptic = require('neataptic'); var network = new neataptic.architect.LSTM(11, 6, 11);

var trainingData = [
    { input: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], output: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
    { input: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], output: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
    { input: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], output: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] },
    { input: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], output: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
    { input: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], output: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
    { input: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], output: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
    { input: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], output: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] },
];

network.train(trainingData, {
    log: 500,
    iterations: 6000,
    error: 0.03,
    clear: true,
    rate: 0.05,
});

var results = { "results": [] };
for (var i = 0; i < 10; i++) {
    var input = output;
    var output = Math.round(network.activate([input]));
    results["results"].push(output);
}

code always returns null. I'm not sure if i'm doing something wrong but I didn't see any documentations regarding multiple inputs and multiple outputs. Let me know if i'm doing something wrong or if this is a genuine problem. Thanks.