Slide 1

Slide 1 text

Mobile, AI and Tensorflow Supriya Srivatsa

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

NEURAL NETWORKS Human anatomy inspired learning network.

Slide 5

Slide 5 text

Neural Networks

Slide 6

Slide 6 text

Neural Networks

Slide 7

Slide 7 text

Neural Network – A Peek Inside

Slide 8

Slide 8 text

Deep Neural Network

Slide 9

Slide 9 text

PREDICTION AND INFERENCE How it works today. How it shall work tomorrow.

Slide 10

Slide 10 text

“Transfer to Infer” Approach

Slide 11

Slide 11 text

Why On-Device Prediction • Data Privacy • Poor internet connections • Questionable user experience

Slide 12

Slide 12 text

To The Rescue…

Slide 13

Slide 13 text

TensorFlow • Tensor: N Dimensional Arrays • Open source software library for numerical computation using data flow graphs.

Slide 14

Slide 14 text

TensorFlow – Data Flow Graphs • Nodes represent mathematical functions • Edges represent tensors.

Slide 15

Slide 15 text

Tensorflow – “Deferred Execution” Model • Graph first. Computation Afterward. import tensorflow as tf x = tf.constant(10) y = tf.Variable(x + 5) print(y)

Slide 16

Slide 16 text

Tensorflow – “Deferred Execution” Model • Graph first. Computation Afterward. import tensorflow as tf x = tf.constant(10) y = tf.Variable(x + 5) model = tf.global_variables_initializer() with tf.Session() as session: session.run(model) print(session.run(y))

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Packaging the App and the Model

Slide 20

Slide 20 text

QUANTIZATION Compress. And Compress More.

Slide 21

Slide 21 text

Quantization • Round it up • Transform: round_weights • Compression rates: ~8% => ~70% • Shrink down node names • Transform: obfuscate_names • Eight bit calculations

Slide 22

Slide 22 text

Quantization - Eight Bit Calculations

Slide 23

Slide 23 text

Quantization - Eight Bit Calculations

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

IMPLEMENTATION Code Away! ☺

Slide 26

Slide 26 text

Implementation build.gradle buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' } }

Slide 27

Slide 27 text

Implementation 1. Load 2. Feed 3. Run 4. Fetch

Slide 28

Slide 28 text

Implementation 1. Load the model 2. Feed in the input 3. Run the model 4. Fetch the output TensorFlowInferenceInterface inferenceInterface = new TensorFlowInferenceInterface(assetManager, modelFile);

Slide 29

Slide 29 text

Implementation 1. Load the model 2. Feed in the input 3. Run the model 4. Fetch the output // feed(String s, float[] floats, long… longs) inferenceInterface.feed(inputName, floatValues, 1, inputSize, inputSize, 3);

Slide 30

Slide 30 text

Implementation 1. Load the model 2. Feed in the input 3. Run the model 4. Fetch the output inferenceInterface.run(outputNames);

Slide 31

Slide 31 text

Implementation 1. Load the model 2. Feed in the input 3. Run the model 4. Fetch the output // fetch(String s, float[] floats) inferenceInterface.fetch(outputName, outputs);

Slide 32

Slide 32 text

APPLICATIONS Awesomeness.

Slide 33

Slide 33 text

Google Translate

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content