The Wayback Machine - https://web.archive.org/web/20221031135305/https://github.com/BrainJS/brain.js/blob/master/examples/javascript/childrens-book.js
Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
const brain = require('brain.js');
const trainingData = [
'Jane saw Doug.',
'Doug saw Jane.',
'Spot saw Doug and Jane looking at each other.',
'It was love at first sight, and Spot had a frontrow seat. It was a very special moment for all.',
];
const lstm = new brain.recurrent.LSTM();
const result = lstm.train(trainingData, {
iterations: 1500,
log: (details) => console.log(details),
errorThresh: 0.011,
});
console.log('Training result: ', result);
const run1 = lstm.run('Jane');
const run2 = lstm.run('Doug');
const run3 = lstm.run('Spot');
const run4 = lstm.run('It');
console.log('run 1: Jane' + run1);
console.log('run 2: Doug' + run2);
console.log('run 3: Spot' + run3);
console.log('run 4: It' + run4);