Run Deep Learning Models in the Browser with JavaScript and ConvNetJS
Christoph Körner
Slides available via http://bit.ly/jazoon2017-dl
About me
Agenda
Y THO
Source: twitter.com/lazygamereviews
Why JavaScript might be a thing for DL
Besides Education
Runs in the Browser
Source: chaosmail.github.io/caffejs
...and hence almost anywhere
Ridiculously easy Debugging
Source: chaosmail.github.io/caffejs
Interactive Visualization
Source: ConvNetJS - MNIST
Intro to Neural Nets
(Supervised Classification)
Pedestrian or cyclist?
Dataset
x0
x1
Annotated Dataset
Pedestrian
Cyclist
x0
x1
Random Separation Line
Pedestrian
Cyclist
x0
x1
Line Equation
y = w * x + b
Line Equation
y = w * x + b
Distance from the line
weights
bias
Input data
Line Equation
x
y
b
w
Line Equation
x0
y
b
w
x1
Line Equation (simplified)
x0
y
w
x1
Let’s classify the samples
Pedestrian
Cyclist
x0
x1
Activation function
+1
-1
Pedestrian
Cyclist
x0
x1
Activation function
x0
y
w
x1
Step function:
map to -1 and +1
Neuron
x0
y
x1
How good are the predicted classes?
Pedestrian
Cyclist
x0
x1
+1
-1
Error/Loss function
Wrong side!
Pedestrian
Cyclist
x0
x1
+1
-1
Error/Loss function
x0
y
w
x1
Compute Error
ytrue
Optimization (e.g. Gradient Descent)
x0
w
x1
Update weights
y
ytrue
Optimization (e.g. Gradient Descent)
Pedestrian
Cyclist
x0
x1
Optimization (e.g. Gradient Descent)
Pedestrian
Cyclist
x0
x1
Optimization (e.g. Gradient Descent)
Pedestrian
Cyclist
x0
x1
Optimization (e.g. Gradient Descent)
Pedestrian
Cyclist
x0
x1
Wrong side!
Multiple Neurons
Pedestrian
Cyclist
+1
-1
+1
-1
x0
x1
Multiple Neurons
x0
y0
x1
y1
Multiple Neurons
Pedestrian
Cyclist
+1
-1
x0
x1
Multiple Layers
x0
x1
y
Summary (Neural Nets)
Summary (Neural Nets)
Summary (Neural Nets)
x0
x1
y
Inference
Back-Propagation
Demo: Tensorflow Playground
Source: playground.tensorflow.org
Ingredients for Deep Learning
Fully Connected Layer
x0
x1
y
x2
x3
Usually very large! e.g. 3x227x227
Hence a large number of params e.g. 3x227x227 * 2
Convolution (weight sharing)
x0
x1
y
x2
x3
Convolution (weight sharing)
x0
x1
y
x2
x3
Convolution (weight sharing)
x0
x1
y
x2
x3
Demo: MNIST Classification (Training)
Source: ConvNetJS - MNIST
Demo: Deep Learning Models
Source: chaosmail.github.io/caffejs
Demo: DeepDream
Demo: DeepDream
Many pretrained models available
Summary (Deep Learning)
JavaScript Ingredients for Deep Learning
Challenges in JavaScript (in the Browser)
JavaScript Frameworks for Deep Learning
Name | Year | Inference | Backprop | GPU | Comp. |
Dec. 2013 | yes | yes | | ConvNetJS | |
May 2016 | yes | yes | | Caffe | |
Aug. 2016 | yes | | yes | Keras | |
Jul. 2017 | yes | yes | yes | Keras/ TensorFlow |
It’s time for some more demos
Teachable Machine
Authors: Støj, Use All Five, Creative Lab and PAIR teams at Google; Source: teachablemachine.withgoogle.com
Fast Neural Style Transfer
Authors: Reiichiro Nakano; Source: reiinakano.github.io/fast-style-transfer-deeplearnjs
Sentiment Classification
Authors: Leon Chen (MD.ai); Source: transcranial.github.io/keras-js/#/imdb-bidirectional-lstm
RNN for Melody Creation
Authors: Magenta (a Google Brain project); Source: deeplearnjs.org/demos/performance_rnn
Take-home Messages
One more thing..
It’s an exciting time for JavaScript developers interested in AI and DL!
Thanks!
Slides are available:
bit.ly/jazoon2017-dl