I'm working on a neuronnal network and I'm trying to do prediction. For that I have an array of array that containt value and I would like to know what will be the next one.
Just to practice I did something really simple but it don't work (the value returned is wrong), Can you explain me wait I'm missing ?
const NN = new brain.recurrent.LSTMTimeStep({
inputSize: 2,
hiddenLayers: [10],
outputSize: 2,
});
let data = [
[1, 2],
[2, 4],
[3, 6],
[4, 8],
[5, 10],
[6, 12],
[7, 14],
[8, 16],
[9, 18],
[10, 20],
[11, 22],
[12, 24],
[13, 26],
[14, 28]
];
const config = {
log: true,
logPeriod: 100,
errorThresh: 0.01,
iterations: 4000
}
NN.train(data, config);
let output = NN.forecast(data, 1);
console.log(output)
On this I want the result to be [15, 30] but it keep return lower value.
Thanks a lot
Changing the number of hidden layer and add some iteration seems to be the solution, my AI wasn't wrong, just not accurate enought
const NN = new brain.recurrent.LSTMTimeStep({
inputSize: 2,
hiddenLayers: [2, 2],
outputSize: 2,
});
let data = [
[1, 2],
[2, 4],
[3, 6],
[4, 8],
[5, 10],
[6, 12],
[7, 14],
[8, 16],
[9, 18],
[10, 20],
[11, 22],
[12, 24],
[13, 26],
[14, 28]
];
const config = {
log: true,
logPeriod: 100,
errorThresh: 0.01,
learningRate: 0.001,
iterations: 40000000
}
NN.train(data, config);
let output = NN.forecast(data, 1);
console.log(output)
With lower learning rate and more iteration the NN have more time to fit perfectly.