Skip to content

Instantly share code, notes, and snippets.

@DaveBben
Created July 2, 2017 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaveBben/9b7d2e7c58bbe992923f584f48fb3eef to your computer and use it in GitHub Desktop.
Save DaveBben/9b7d2e7c58bbe992923f584f48fb3eef to your computer and use it in GitHub Desktop.
const brain = require('brain.js');
var net = new brain.NeuralNetwork();
let ops = [
{ input: [.7], output: [.5] },
{ input: [.71], output: [.5] },
{ input: [.708], output: [.5] },
{ input: [.704], output: [.53] },
{ input: [.708], output: [.53] },
{ input: [.68], output: [.55] },
{ input: [.58], output: [.46] },
{ input: [.7], output: [.5] },
]
for (let i = 0; i < 30000; i += 1) {
ops.push({ input: [getRandomArbitrary(0.65, 0.75)], output: [getRandomArbitrary(0.48, 0.59)] })
}
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
net.train(ops, { log: true, errorThresh: 0.0001, iterations: 50});
console.log(net.run([.62])); // 3.1 miles -- 30.6 minutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment