JavaScript™ belongs to Oracle
Deep Learning is all about linalg
JavaScript sucks at linalg
JavaScript no more sucks at linalg
JavaScript even has autodiff now
Quick facts
- Started in 2017 as deeplearn.js
- Written in TypeScript
- ~10 developers from Google (Brain)
Official features
- Develop ML in the browser
- Run existing models
- Retrain existing models
Core API
- Copied from Python; naming convention changed
- Eager-only
- No device pinning/selection
- A few quirks
- There are API differences
- No
tf.nn
- Semi-manual memory management
- "web friendly" model format
Tensorflow model formats zoo
- GraphDef = graph + [variable values - 2GB limit]
- Checkpoint = variable values
- Summary (aka Tensorboard) = GraphDef + key-value
- MetaGraph = GraphDef + tags + i/o + Checkpoint
- SavedModel = one or more MetaGraph-s
- ModuleDef (aka Hub) = special SavedModel
- Keras = hdf5 with arch and weights
- 🎉 TensorFlow.js = GraphDef + JSON + sharded weights
Semi-manual memory management
- There are various JS engines
- There are various GC implementations
- We allocate memory like hungry 🐺
Semi-manual memory management
const y = tf.tidy(() => {
const one = tf.scalar(1);
const a = tf.scalar(2);
const b = a.square();
console.log('numTensors (in tidy): ' + tf.memory().numTensors);
return b.add(one);
});
console.log('numTensors (outside tidy): ' + tf.memory().numTensors);
y.print(); // y = 2 ^ 2 + 1
Tensor IO
tf.Tensor
is immutable
tf.TensorBuffer
is mutable
- No efficient
set()
Progressive GAN
Transfer Learning
No webcam found.
To use this demo, use a device with a webcam.
Load tfjs!
0
0
Let's swap out Python with JavaScript
Installation for Node.js
npm install @tensorflow/tfjs @tensorflow/tfjs-node
or @tensorflow/tfjs-node-gpu
ijavascript
npm install ijavascript-await
- Node.js driver for Jupyter
- Deals with async/await
- Good integration into the notebook
Summary
- Much fun and easy
- Very early days
- PoCs work
- TensorFlow is getting even more complex inside