mobile, ai and tensorflow lite - developer summit · mobile, ai and tensorflow lite supriya...
TRANSCRIPT
![Page 1: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/1.jpg)
![Page 2: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/2.jpg)
Mobile, AI and Tensorflow Lite Supriya Srivatsa
![Page 3: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/3.jpg)
![Page 4: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/4.jpg)
![Page 5: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/5.jpg)
NEURAL NETWORKS
Human anatomy inspired learning network.
![Page 6: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/6.jpg)
Neural Networks
![Page 7: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/7.jpg)
Neural Networks
![Page 8: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/8.jpg)
Neural Network – A Peek Inside
![Page 9: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/9.jpg)
Deep Neural Network
![Page 10: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/10.jpg)
PREDICTION AND INFERENCE
How it works today. How it shall work tomorrow.
![Page 11: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/11.jpg)
“Transfer to Infer” Approach
![Page 12: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/12.jpg)
Why On-Device Prediction
• Data Privacy
• Poor internet connections
• Questionable user experience
![Page 13: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/13.jpg)
To The Rescue…
![Page 14: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/14.jpg)
TensorFlow
• Tensor: N Dimensional Arrays
• Open source software library for numerical computation using data flow graphs.
![Page 15: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/15.jpg)
TensorFlow – Data Flow Graphs
• Nodes represent mathematical functions
• Edges represent tensors.
![Page 16: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/16.jpg)
Tensorflow – “Deferred Execution” Model
• Graph first. Computation Afterward.
import tensorflow as tf
x = tf.constant(10)
y = tf.Variable(x + 5)
print(y)
![Page 17: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/17.jpg)
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))
![Page 18: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/18.jpg)
![Page 19: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/19.jpg)
![Page 20: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/20.jpg)
Packaging the App and the Model
![Page 21: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/21.jpg)
QUANTIZATION
Compress. And Compress More.
![Page 22: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/22.jpg)
Quantization
• Round it up
• Transform: round_weights
• Compression rates: ~8% => ~70%
• Shrink down node names
• Transform: obfuscate_names
• Eight bit calculations
![Page 23: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/23.jpg)
Quantization - Eight Bit Calculations
![Page 24: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/24.jpg)
Quantization - Eight Bit Calculations
![Page 25: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/25.jpg)
![Page 26: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/26.jpg)
IMPLEMENTATION
Code Away!
![Page 27: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/27.jpg)
Implementation
build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
} }
![Page 28: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/28.jpg)
Implementation
1. Load
2. Feed
3. Run
4. Fetch
![Page 29: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/29.jpg)
Implementation
1. Load the model
2. Feed in the input
3. Run the model
4. Fetch the output
TensorFlowInferenceInterface inferenceInterface =
new TensorFlowInferenceInterface(assetManager, modelFile);
![Page 30: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/30.jpg)
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);
![Page 31: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/31.jpg)
Implementation
1. Load the model
2. Feed in the input
3. Run the model
4. Fetch the output
inferenceInterface.run(outputNames);
![Page 32: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/32.jpg)
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);
![Page 33: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/33.jpg)
APPLICATIONS
Awesomeness.
![Page 34: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/34.jpg)
Google Translate
![Page 35: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/35.jpg)
![Page 36: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/36.jpg)
![Page 37: Mobile, AI and Tensorflow Lite - Developer Summit · Mobile, AI and Tensorflow Lite Supriya Srivatsa . NEURAL NETWORKS Human anatomy inspired learning network. Neural Networks . Neural](https://reader031.vdocuments.net/reader031/viewer/2022013010/5fba3dd79205941a3a61f31c/html5/thumbnails/37.jpg)
@greatindiandev bit.ly/gidslinkedin www.developersummit.com
Conference and Deep Dive Sessions
April 24-28, IISc Bangalore
TM
2018
Register early and get the best discounts!