Novabrain
Novabrain is a javascript neural network library for Node.js and browser. This library implements a multilayer perceptron network that you can train to learn XOR, OR, AND ... for example.
In Node.js
You can install Novabrain with npm
$ npm install novabrain --save
var Novabrain = ;var Neuron = NovabrainNeuron;var Layer = NovabrainLayer;var Network = NovabrainNetwork;var Trainer = NovabrainTrainer;var Transfer = NovabrainTransfer;var Samples = NovabrainSamples;
In the browser
You can also use the minified version to increase your web page loading
Create a network
Constructor expected an intergers suite. The first value is the input size The last value is the output size Between this values you can set many hidden size (2, 3, ..., 1)
21;231;5442;
Samples
Novabrain samples contains training and config for basics functions
NovabrainSamplesXORNovabrainSamplesANDNovabrainSamplesOR
Back Propagation Training
This example shows how the neural network is trained to learn XOR
var network = 21;var trainer = network; trainer; console; // [~0.05]console; // [~0.93]console; // [~0.93]console; // [~0.09] networktransfer = NovabrainTransferBOOLEAN; console; // [false]console; // [true]console; // [true]console; // [false]
Transfer functions
The transfer functions are used to change the value of the outputs. By default, neurons uses a Logistic Sigmoid transfer. You can change those properties the following way.
networktransfer = NovabrainTransferBOOLEAN; console; // [false]console; // [true]console; // [true]console; // [false]
LOGISTIC
Return logistic sigmoid values
HARDLIMIT
Return 0 or 1 values
BOOLEAN
Return boolean values like HARDLIMIT
IDENTIFY
Return sum values without transfer
TANH
Return values between -1 and 1
Export and import data
var n1 = 21;var n2 = 21; n2;// orn2; var results = n2);
Create a standalone function
By default the transfer function used is LOGISITC but you can change this by two ways. Define your custom transfer before the standalone function export or set the transfer param when you use the standalone function.
var standalone = network;var booleanResults = );
var standalone = network;var booleanResults = );var tanhResults = );
Mocha is used for unit testing
$ npm test
$ make tests
$ npm install mocha -g
$ mocha
Contribute
Novabrain is an Open Source project started in France by François Mathey. Anybody is welcome to contribute to the development of this project.
If you want to contribute feel free to send PR's, just make sure to run the make before submiting it. This way you'll run all the test specs and build the web distribution files.
$ make
Thank you <3