TensorFlow.js

Vadim Markovtsev, source{d}.

Intro

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

TensorFlow.js

Quick facts

Official features

Run Existing models

API levels 
{
CoreKeras

Core API

Core API

Tensorflow model formats zoo

  1. GraphDef = graph + [variable values - 2GB limit]
  2. Checkpoint = variable values
  3. Summary (aka Tensorboard) = GraphDef + key-value
  4. MetaGraph = GraphDef + tags + i/o + Checkpoint
  5. SavedModel = one or more MetaGraph-s
  6. ModuleDef (aka Hub) = special SavedModel
  7. Keras = hdf5 with arch and weights
  8. 🎉 TensorFlow.js = GraphDef + JSON + sharded weights

Semi-manual memory management

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

Keras API

Keras is not tf.keras

Keras API

Live demo 1

Mobilenet

    Live demo 2

    Progressive GAN

    Live demo 3

    Transfer Learning

    No webcam found.
    To use this demo, use a device with a webcam.
    Load tfjs!
    0
    0

    Examples

    github.com/tensorflow/tfjs-examples

    Live demo 4

    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

    Summary

    Summary

    bit.ly/2Urz262