ConvNetJs2
ConvNetJs2 is a successor of the ConvNetJS project 。
ConvNetJs2 is a Javascript implementation of Neural networks, together with nice browser-based demos. It currently supports:
- Common Neural Network modules (fully connected layers, non-linearities)
- Classification (SVM/Softmax) and Regression (L2) cost functions
- Ability to specify and train Convolutional Networks that process images
- An experimental Reinforcement Learning module, based on Deep Q Learning
For much more information, see the ConvNetJs2 main page at https://ccc-js.github.io/convnetjs2demo/
Note: @karpathy is not actively maintaining ConvNetJS anymore because he don't have time. So @ccckmit fork the project and rename it to ConvNetJs2.
Online Demos
- Convolutional Neural Network on MNIST digits
- Convolutional Neural Network on CIFAR-10
- Toy 2D data
- Toy 1D regression
- Training an Autoencoder on MNIST digits
- Deep Q Learning Reinforcement Learning demo
- Image Regression ("Painting")
- Comparison of SGD/Adagrad/Adadelta on MNIST
Example Code
You may found more node.js examples for the ConvNetJs2 in the following project.
Here's a minimum example of defining a 2-layer neural network and training it on a single data point:
// species a 2-layer neural network with one hidden layer of 20 neuronsvar layer_defs = ;// input layer declares size of input. here: 2-D data// ConvNetJS works on 3-Dimensional volumes (sx, sy, depth), but if you're not dealing with images// then the first two dimensions (sx, sy) will always be kept at size 1layer_defs;// declare 20 neurons, followed by ReLU (rectified linear unit non-linearity)layer_defs; // declare the linear classifier on top of the previous hidden layerlayer_defs; var net = ;net; // forward a random data point through the networkvar x = 03 -05;var prob = net; // prob is a Vol. Vols have a field .w that stores the raw data, and .dw that stores gradientsconsole; // prints 0.50101 var trainer = net learning_rate:001 l2_decay:0001;trainer; // train the network, specifying that x is class zero var prob2 = net;console;// now prints 0.50374, slightly higher than previous 0.50101: the networks// weights have been adjusted by the Trainer to give a higher probability to// the class we trained the network with (zero)
and here is a small Convolutional Neural Network if you wish to predict on images:
var layer_defs = ;layer_defs; // declare size of input// output Vol is of size 32x32x3 herelayer_defs;// the layer will perform convolution with 16 kernels, each of size 5x5.// the input will be padded with 2 pixels on all sides to make the output Vol of the same size// output Vol will thus be 32x32x16 at this pointlayer_defs;// output Vol is of size 16x16x16 herelayer_defs;// output Vol is of size 16x16x20 herelayer_defs;// output Vol is of size 8x8x20 herelayer_defs;// output Vol is of size 8x8x20 herelayer_defs;// output Vol is of size 4x4x20 herelayer_defs;// output Vol is of size 1x1x10 here net = ;net; // helpful utility for converting images into Vols is includedvar x = convnetjsvar output_probabilities_vol = net
Getting Started
A Getting Started tutorial is available on main page.
The full Documentation can also be found there.
See the build/convnet.js page for this project to get the ConvNetJs2 library.
You may download a copy from the following direct link.
Compiling the library from src/ to build/
If you would like to add features to the library, you will have to change the code in src/
and then compile the library into the build/
directory. The compilation script use browserify to generate the distribute file for web browser.
The compilation is done using an npm script by browserify
$ npm run build
The output files will be in build/
Use in Node
The library is also available on node.js:
- Install it:
$ npm install convnetjs2
- Use it:
var convnetjs = require("convnetjs2");
License
MIT