Created
July 2, 2017 00:03
-
-
Save DaveBben/9b7d2e7c58bbe992923f584f48fb3eef to your computer and use it in GitHub Desktop.
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'); | |
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