Created
November 30, 2016 15:02
-
-
Save robertleeplummerjr/0384bdd8e6c6b672279780943d9de434 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
it('can predict a phrase when given the first letter', () => { | |
const phrase = 'bob'; | |
const vocab = new Vocab(['b', 'o']); | |
const net = new GRU({ | |
inputSize: 3, | |
inputRange: vocab.characters.length, | |
outputSize: 3 | |
}); | |
for (var i = 0; i < 100; i++) { | |
//train | |
net.run(vocab.toIndexes(phrase)); | |
//visual feedback | |
if (i % 10 === 0) { | |
console.log(vocab.toCharacters(net.predict()).join('')); | |
} | |
} | |
//test when given "b", should add "ob" to it | |
assert.equal(vocab.toCharacters(net.predict(vocab.toIndexes('b'))).join(''), phrase); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment