Skip to content

Getting Started

razorsyntax edited this page Sep 7, 2017 · 7 revisions

Setting up your neural network

The neural network is represented by a dynamic JSON object.

The way to think about creating your network is in parts from the top down.

* Create the network obj
* Add hidden layers
* Add neurons
* Set your expected target array
* Initialize your network with the initial inputs

Create your Network Object:

var HAL = new NeuralNetwork(/*string*/ "HAL9000");

Add hidden layers and neurons:

var neurons = {
        "name": "MNIST",
        "type": "hidden",
        "neurons": NeuronArray(/*int*/ numOfNeurons, /*string*/ activationFunctionType)
    }

HAL.createLayer(numOfLayers, neurons);

activationFunctionType is the name of the activation function you want to use for those neurons. Valid values are: "logsig", "tanh", "linear", "satlin", "arctan", "gaussian"

Set your expected target array

HAL.setTarget( [0, 0, 1] );

Initialize network with initial inputs

HAL.init( [0, 0, 1] );

HAL.init(SomeInputs) initializes the network by generating pseudo-random values between 0 and 1 using a Gaussian distribution for all neuron weights and biases in the hidden and output layers.

Your neural network is ready to train.

Training your Network

The Train(...) function, as the name suggestions, trains to your network object.

Train(HAL, inputs, rate, trainCycles, false);

Train(...) parameters:

* Neural Network Object: {}
* Input Array: []
* Learning Rate, int
* Number of Train Cycles: int
* Enable Error Calculations: bool

That's it.

Once Train(...) runs, the network trains itself and the network object is updated.

See the file sampleNN.json to see an already trained network.

Clone this wiki locally