Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index: 1, result: 1
- index: 2, result: 2
- index: 3, result: 3
- index: 4, result: 4
- index: 5, result: 1
- index: 6, result: 2
- index: 7, result: 3
- index: 8, result: 4
- index: 9, result: 1
- index: 10, result: 2
- index: 11, result: 3
- index: 12, result: 4
- etc.
- const brain = require('brain.js');
- const network = new brain.recurrent.LSTMTimeStep();
- let trainingData = [];
- for (let i = 1, j = [4, 1, 2, 3]; i <= 100; i++) {
- trainingData.push({input: {index: i}, output: {result: j[i%4]}});
- }
- network.train(trainingData);
- console.log(network.run({index: 101}));
- console.log(network.run({index: 102}));
- console.log(network.run({index: 103}));
- console.log(network.run({index: 104}));
- /*
- { result: 2.564828634262085 }
- { result: 2.564828634262085 }
- { result: 2.564828634262085 }
- { result: 2.564828634262085 }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement