nnjs

Stars
16

nn.js : high performance (not yet) neural networks for the Browser

This package is in all respects inferior to convnet.js

This package is not meant to replace the excellent convnet.js, but provide a lower-level package.

A fast low-level javascript package for multi-threaded neural net layers for the browser.

For now, this package only implements the forward ops, and does not implement backward.

It is useful when porting Torch models to the browser.

For example, it powers the browser demo in: http://soumith.ch/eyescream

Layers:

nn.SpatialConvolution(weight, bias, padH, padW) 
nn.SpatialMaxPooling(kH, kW, dH, dW)
nn.ReLU()
nn.Linear(weight, bias)
nn.View(shape)
nn.Sequential()
nn.JoinTable(dim)
nn.ParallelTable()
nn.Identity()

###Uses:

  • [TODO] Web workers for using multiple cores
  • [TODO] SIMD optimizations if the browser supports SIMD.js or WebAssembly

###Dependencies:

  • ndarray
  • ndarray-fill
  • msgpack-js

###Unit tests:

Unit tests can be run via nodejs.

$ npm -g install mocha
$ cd nnjs
$ mocha 

  SpatialConvolution
       Should compare against torch convolutions (126ms)

  SpatialMaxPooling
       Should compare against torch SpatialMaxPooling

  Linear
       Should compare against torch Linear layer

  Loader
       Should load a full multi-layer model and compare against torch result (3051ms)


  4 passing (3s)

Building for the browser

npm install -g browserify
browserify -r ./js/init.js:nn -r ndarray -r ndarray-fill -o static/js/nn.js