2016-10-13 16:52:02 -04:00
2016-10-13 16:52:02 -04:00
2016-10-12 12:03:19 -04:00
2016-08-26 23:53:13 -04:00
2016-10-11 17:53:46 -04:00
2016-10-06 03:03:22 -04:00
2016-08-19 23:02:21 -04:00
2016-10-13 00:31:49 -04:00
2016-10-12 12:03:24 -04:00
2016-10-06 17:12:11 -04:00
2016-10-06 17:12:11 -04:00

Keras.js

Run trained Keras models in your browser, GPU-powered using WebGL.

Interactive Demos

  • Basic convolutional neural network for MNIST

  • Convolutional variational autoencoder trained on MNIST, with image generation from the latent space (decoder part)

  • 50-layer residual network, trained on ImageNet

  • Inception V3 network, trained on ImageNet

  • Bidirectional LSTM for sentiment classification, trained on the IMDB movie reviews dataset

Why?

  • Eliminate need for backend infrastructure.

  • Interactivity

  • Visualization

  • Education (great example being convnetjs, of course)

  • Debugging of your neural network

Usage

model = Sequential()
...
model = Model()
  1. GPU support is powered by weblas.

API

Notes

WebWorkers and their limitations

Kera.js can be run in a WebWorker separate from the main thread. Because Keras.js performs a lot of synchronous computations, this can prevent the UI from being affected. However, one of the biggest limitations of WebWorkers is the lack of <canvas> (and thus WebGL) access. So the benefits gained by running Keras.js in a separate thread are offset by the necessity of running it in CPU-mode only. In other words, one can run Keras.js in GPU mode only on the main thread.

WebGL MAX_TEXTURE_SIZE

In GPU mode, tensor objects are encoded as WebGL textures prior to computations. The size of these tensors are limited by gl.getParameter(gl.MAX_TEXTURE_SIZE), which differs by hardware/platform. See here for typical expected values. The may be an issue in convolution layers after im2col. For example, in the Inception V3 network demo, im2col in the 1st convolutional layer creates a 22201 x 27 matrix, and 21609 x 288 matrices in the 2nd and 3rd convolutional layers. The size along the first dimension exceeds most MAX_TEXTURE_SIZE, 16384, and therefore must be split. Matrix mutiplications are performed with the weights for each split tensor and then combined. In this case, a weblasTensorsSplit property is available on the Tensor object when createWeblasTensor() is called (see src/Tensor.js). See src/layers/convolutional/Convolution2D.js for an example of its usage.

Development / Testing

License

MIT

S
Description
Run Keras models (tensorflow backend) in the browser, with GPU support
Readme MIT
295 MiB
Languages
Jupyter Notebook 58.8%
JavaScript 40.4%
HTML 0.6%
Python 0.2%