Created
September 4, 2018 18:59
-
-
Save kmaher9/d57660dfa78167b8acc63eb90e0d7974 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
var fs = require('fs') | |
var brain = require('brain.js') | |
var bPath = "Z:\\Development\\Javascript\\NodeJS\\Neural Networks\\Brain.JS\\002\\src\\dataset\\business" | |
var tPath = "Z:\\Development\\Javascript\\NodeJS\\Neural Networks\\Brain.JS\\002\\src\\dataset\\tech" | |
var sample = "Z:\\Development\\Javascript\\NodeJS\\Neural Networks\\Brain.JS\\002\\src\\dataset\\011.txt" | |
var net = new brain.recurrent.LSTM() | |
var bFiles = fs.readdirSync(bPath) | |
var outputs = [] | |
for (var i = 0; i < 4; i++) { | |
var file = bFiles[i] | |
var content = fs.readFileSync(bPath + "\\" + file) | |
outputs.push({input: content, output: 'business' }) | |
} | |
var tFiles = fs.readdirSync(tPath) | |
for (var i = 0; i < 4; i++) { | |
var file = tFiles[i] | |
var content = fs.readFileSync(tPath + "\\" + file) | |
outputs.push({input: content, output: 'technology' }) | |
} | |
console.log("training on " + outputs.length + " inputs ...") | |
net.train(outputs, { | |
log: true | |
}) | |
var testFile = fs.readFileSync(sample) | |
var output = net.run(testFile); | |
console.log(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment