node_neural_net
v1.1.2
Published
A utility to create and train a feed-forward neural network in Node.js
Downloads
3
Maintainers
Readme
node_neural_net
A utility to create and train a feed-forward neural network in Node.js
Examples
MNIST Handwritten Digit Recognition
let NeuralNet = require('node_neural_net');
let mnist = require('mnist');
// use a third party library to obtain training data
let set = mnist.set(8000, 2000);
let trainingSet = set.training;
// create input and output sets
let sample_in = new Array(8000);
let sample_out = new Array(8000);
for (let i = 0; i < 8000; ++i) {
sample_in[i] = trainingSet[i].input;
sample_out[i] = trainingSet[i].output;
}
// create a neural network with 784 input neurons (1 for each pixel),
// 2 hidden layers with 16 neurons each,
// and 10 output neurons (1 for each digit).
let nn = new NeuralNet([784, 16, 16, 10]);
// nn.train(input_set, output_set, batch_size, learning_rate)
nn.train(sample_in, sample_out, 100, 0.1);
// save model information in a file called 'model.js' for later use
nn.save_weights('model.js');