Ray Hilton - @rayh Eliiza - @EliizaAI
About Us
Data Science
Machine Learning
Artificial Intelligence
Data Engineering
Data Ops
Video Multi-Classification
Audio Transcription
Predicting Renewable Energy Generation
Natural Language Processing
Operational Forecasting
Sports Data Analysis
Anomaly Detection
12 8 1.5
YearsCountriesPeople
33% 60% 0%
Female
Engineers
Female Data
Scientists
Academic
Background
@EliizaAI
info@eliiza.com.au
#TFDevSummit2019
Sunnyvale, CA 6-7 March
~400 people
Adobe, Apple, Twitter, Microsoft,
Nike, TWiML, Small
Consultancies, Research
Institutions, Google (obviously)
TF2
Simpler APIs
# TensorFlow 1.X
outputs = session.run(
f(placeholder),
feed_dict={placeholder: input}
)
# TensorFlow 2.0
outputs = f(input)
Simpler APIs
from keras.models import Sequential
from keras.layers import Dense
model = Sequential([
Dense(64, activation='relu')),
Dense(64, activation='relu')),
Dense(10, activation='softmax'))
])
Keras API
import tensorflow as tf
from tensorflow.keras.layers import Dense
model = tf.keras.Sequential([
Dense(64, activation='relu')),
Dense(64, activation='relu')),
Dense(10, activation='softmax'))
])
TensorFlow 💖 Keras
Eager & Lazy Execution
x = [[2.]]
m = tf.matmul(x, x)
print("hello, {}".format(m))
>> hello, [[4.]]
Eager Execution
👏
@tf.function
def square_if_positive(x):
x = x * x if x > 0 else x = 0
return x
square_if_positive(tensor)
AutoGraph
Distribution Strategies
model = tf.keras.Sequential(...)
model.compile(loss='mse', optimizer='sgd').
model.fit(dataset, epochs=2)
model.evaluate(dataset)
Strategy Scopes
strategy = tf.distribute.MirroredStrategy()
with strategy.scope():
model = tf.keras.Sequential(...)
model.compile(loss='mse', optimizer='sgd').
model.fit(dataset, epochs=2)
model.evaluate(dataset)
Multiple GPUs on One Machine
strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy()
with strategy.scope():
model = tf.keras.Sequential(...)
model.compile(loss='mse', optimizer='sgd').
model.fit(dataset, epochs=2)
model.evaluate(dataset)
Multiple GPUs Across Multiple Machines
strategy = tf.distribute.experimental.TPUStrategy()
with strategy.scope():
model = tf.keras.Sequential(...)
model.compile(loss='mse', optimizer='sgd').
model.fit(dataset, epochs=2)
model.evaluate(dataset)
Train on TPUs
strategy = tf.distribute.experimental.ParameterServerStrategy()
with strategy.scope():
model = tf.keras.Sequential(...)
model.compile(loss='mse', optimizer='sgd').
model.fit(dataset, epochs=2)
model.evaluate(dataset)
Train using Parameter Servers
TF2
● Better documentation
● Broken up the monolith - take what you need
● Reduced complexity (deleted stuff)
● Better API (hello keras)
● Eager Execution by default
● … but lazily executed functions
● Strategy Scopes for distributing work
TFX
What is TFX
What does TFX provide?
● TensorFlow Data Validation (TFDV)
● TensorFlow Transform (TFT)
● TensorFlow Model Analysis (TFMA)
● TensorFlow Metadata (TFMD)
● ML Metadata (MLMD)
Data Validation
Transform
Transform: Preprocessing Example
Model Analysis
Evaluator
Metadata
TFJS
What is it?
● Complete JS implementation of TF
● No drivers
● Interactive
● Local Training & Inference (privacy)
● Uses WebGL to accelerate linear algebra (See TFJS-core)
Versatile
● Browser
● Server-Side (Node JS)
● Desktop (via Electron, etc)
● Mobile (😮)
Browser
<script
src="https://cdn.jsdelivr.net/npm/@tensorfl
ow/tfjs@1.0.0/dist/tf.min.js"></script>
Quick Start: Browser
Body Pix
Node JS
import * as tf from ‘tfjs-node’;
Quick Start: Node
import * as tf from ‘tfjs-node-gpu’;
Quick Start: Node + CUDA
TFLite
Quantizing
Selective Ops
$ tflite_convert 
--output_file=/tmp/foo.tflite 
--graph_def_file=/tmp/foo.pb 
--input_arrays=input 
--output_arrays=Reshape_1 
--target_ops=TFLITE_BUILTINS,SELECT_TF_OPS
Selective Ops
GPU Delegate
// NEW: Prepare GPU delegate.
GpuDelegate delegate = new GpuDelegate();
Interpreter.Options options = (new
Interpreter.Options()).addDelegate(delegate);
// Set up interpreter.
Interpreter interpreter = new Interpreter(model, options);
// Run inference.
writeToInputTensor(inputTensor);
interpreter.run(inputTensor, outputTensor);
readFromOutputTensor(outputTensor);
delegate.close();
GPU Delegate in Android
Swift API!
import TensorFlowLite
let interpreter = try Interpreter(
modelPath: modelPath,
options: options)
try interpreter.invoke()
let outputTensor = try interpreter.output(at: 0)
Swift API
Questions?
Thanks 🙏
References: elz.ai/tf2
Ray Hilton - @rayh Eliiza - @EliizaAI
Quickly mention...
tf.data & tf.datasets
SparkFun
Coral Edge TPU
Coral Edge TPU
Federated TensorFlow
Mesh TensorFlow
Swift for TensorFlow
Thanks (Again)
References: elz.ai/tf2
Ray Hilton - @rayh Eliiza - @EliizaAI
TF Dev Summit 2019

TF Dev Summit 2019