Permalink
Cannot retrieve contributors at this time
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?
brain.js/examples/javascript/childrens-book.js /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (22 sloc)
730 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |