Skip to content

Simple Self-Contained Neural Network toolkit written on JavaScript (usefull as sample or tutorial)

License

Notifications You must be signed in to change notification settings

openlab-vn-ua/NNJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NNJS

Simple Self-Contained Neural Network toolkit written on JavaScript (usefull as sample or tutorial)

Example

Create network

// Create NN.Layers
var IN  = new NN.Layer(28*28, NN.TheNeuronFactory(NN.InputNeuron)); IN.addNeuron(new NN.BiasNeuron());
var L1  = new NN.Layer(28*28, NN.TheNeuronFactory(NN.ProcNeuron)); L1.addNeuron(new NN.BiasNeuron()); 
var OUT = new NN.Layer(10, NN.TheNeuronFactory(NN.ProcNeuron)); // Outputs: 0="0", 1="1", 2="2", ...
// Connect layers
L1.addInputAll(IN);
OUT.addInputAll(L1); 
// Create NN.Network by NN.Layers
var NET = new NN.Network(); NET.addLayer(IN); NET.addLayer(L1); NET.addLayer(OUT);

Train

// NN.doTrain(Net,DATAS, TARGS) // run training session
//var DATAS = [ [...], [...], ... ]; // source data samples (each sample holds values for inputs)
//var TARGS = [ [...], [...], ... ]; // expected result vectors (each result holds expected outputs)
console.log("Training, please wait ...");
if (!NN.doTrain(NET, DATAS, TARGS))
{
  console.log("Training failed!", NET);
}
console.log("Training complete", NET);

Run inference

// NN.doProc(Net,DATA) // run single inference calculation
// Input DATA (must have same count as number of inputs)
// Returns result vector (will have same count as number of outputs)
var CALC = NN.doProc(NET, DATA);

Cousin C++ project: NNCPP

There is a NN engine implementation on c++ with (almost) the same API: https://github.com/openlab-vn-ua/NNCPP

Useful links (and thanks to!)

About

Simple Self-Contained Neural Network toolkit written on JavaScript (usefull as sample or tutorial)

Resources

License

Stars

Watchers

Forks

Packages

No packages published