hal

hal9000js

A JavaScript-based Classifier Neural Network

Showing:

Popularity

Downloads/wk

5

Maintenance

No Maintenance Data Available

Package

Dependencies

1

Size (min+gzip)

133.5KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Looking for contributors to make this Neural Network a swiss-army knife for lightweight, front-end machine learning tasks like classification.

Training Demo Here: https://razorsyntax.github.io/HAL9000/

An easy to use JavaScript-based Neural Network for simple classification.

You can train your network and then transfer the learned results!

var hal9000 = require(‘hal9000js’);

Getting started is really easy...

1) Create your network 2) Add your neurons and layers 3) Initialize the network 4) Train!

Check out the steps below

1) Create your network

var inputs = [0,0,1];
var learningRate = .05;
var trainingCycles = 10000;
var enableErrors = true; // Enables and appends training errors to the Neural Network json.

// Create the network and give it name
var NN = new NeuralNetwork("HAL9000");

2) Add your neurons and layers

// Create a hidden layer with three neurons
var hiddenLayerNeurons = NeuronArray(3, "logsig");

// Create a hidden layer with your hidden layer neurons
NN.createLayer({
    "name": "HiddenLayer",
    "type": "hidden",
    "neurons": hiddenLayerNeurons
}); 

// Create an output layer with three neurons
var outputLayerNeurons = NeuronArray(3, "logsig");

// Create a output layer with your hidden layer neurons
NN.createLayer({
    "name": "MNIST",
    "type": "output",
    "neurons": outputLayerNeurons
});

3) Initialization

// Set the training targets you want your Network to learn (in this case, it's the same as the inputs)
NN.setTarget(inputs);

/* Initialize your Neural Network
 *      This step creates pseudo-random initial weights and biases for your neural network
 *      setting up the initial conditions for training
 */
NN.init(inputs);

4) Train your network

// Returns a JSON object representation of your Neural Network
var trainedResult = Train(NN, inputs, learningRate, trainingCycles, enableErrors);

Use Case

// This is where the magic starts

var input = [1,0,1]; // <-- This input can represent anything you need classified
/**
 * Note:
 *    Let's say you want to classify apples and oranges.
 *    Apples would be represented by [0,1,0] and oranges would be represented by [1,0,0].
 *    When you give the inputs to Prediction(...), it'll output a classified result
 */

var classified = Prediction(trainedResult, input); // "trainedResult" from step 4)

// If you give [1,0,0] to Prediction, you should have values close to [1,0,0] returned!
//   This means your network is trained!

// I'll have a sample demo of a trained network up shortly

Notes:

  • Layers of different sizes don't work yet. Looking for contributors for to help refactor and add additional features.

Future Tasks:

  • Integration with a JavaScript GPU library for crunching larger data sets

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100