Sanbox project to try and use NN libraries for JS. (As the name suggests, it started with only synaptic.js.)
The code is based on this tutorial and uses mnist js library and synaptic.js.
The project is powered by Node.js, so a combination of
npm install
and npm start
should get it running.
If there is no saved network, the code will train a new one
and a bug that prevents program from finishing will appear.
The reasons behind this one are not yet clear,
but you can safely CTRL + C
your way out.
Synaptic.js seems to be unreasonably slow on simple architecures (it seems, it is really build for recurrent NNs), so it is a good idea to try out some other libraries. This article seems to give a brief owerview of several JS NN libraries, and this one is specificaly about brain.js.
The files in repo are:
network.js
is a mnist digit recognising NN's creation, training and running all in one.js
file. It might be more convinient to use it if you just experimenting with the network. To run it, instead ofmain.js
, require it fromapp/index.js
.main.js
is a simple code for loading/creating NN and serializing in to a file. It is a default running option inapp/index.js
. The code can work with eithernumbers-recognition-network.js
orsingle-number-recognition-network.js
. To change the used network, require it form the top ofmain.js
.numbers-recognition-network.js
is a mnist digit recognising NN fromnetwork.js
. It doesn't quite work: it probably needs more neurons on the hidden layer and/or more layers, but, either because of the slow machine, slow library or both, this is hardly achievable. To run it, require it from the top ofmain.js
.single-number-recognition-network.js
is a mnist single digit recognising network. It really seems to work well, hence it is a default running option (it is required from themain.js
).network.json
is the saved network. If it exists, the program will load and use it; if it doesn't exist, the program will train a new one and save it.- Some other networks can be found in
networks/
. brain-mnist-recogniser.js
is a mnist digit recognising NN, built via brain.js library. brain.js learned faster and with less memory and CPU consumption, than synaptic.js, so it could be trained on larger datasets. In particular, a training set of 3000 samples gave ~95% accuracy for the trained network.