Beruflich Dokumente
Kultur Dokumente
§ Open-source devotee
§ Google Developer Experts (Machine Learning)
§ Principal Researcher, KOSSLab., Korea
§ Textcube open-source project maintainer (10th
anniversary!)
§ Physicist / Neuroscientist
§ Adj. professor (Dept. of CSE, Hanyang Univ.)
§ Ph.D in Statistical Physics (complex systems /
computational neuroscience)
Machine Learning Era: All came from dust
§ Machine learning
§ ”Field of study that gives computers the ability to learn without being explicitly programmed”
Arthur Samuel (1959)
§ "A computer program is said to learn from experience E with respect to some class of tasks T
and performance measure P, if its performance at tasks in T, as measured by P, improves with
experience E.” Tom Michel (1999)
A. K. Jain, J. Mao, K. M. Mohiuddin (1996) Artificial Neural Networks: A Tutorial IEEE Computer 29
Winter was coming
§ First winter (1970s)
§ Complex problems: too difficult to construct logic models (by hand)
§ Value network
§ Policy network
§ Principal variation
Flow of TensorFlow
Still less than two years passed.
TensorFlow
§ Open-source software library for machine learning across a range of tasks
§ Developed by Google (Dec. 2015~)
§ Characteristics
§ Python API (like Theano)
§ From 1.0, TensorFlow expands native API binding with Java C, etc.
§ Supports
§ Linux, macOS
§ NVidia GPUs (pascal and above)
Before TensorFlow
§ User-friendly Deep-learning toolkits
§ Caffe (2012)
§ Generalized programming method to researchers
§ Provides common NN blocks
§ Configuration file + training kernel program
§ Theano (2013~2017)
§ User code / configuration part is written in Python
§ Keras (2015~)
§ Meta-framework for Deep Learning programming
§ Supports various backends:
§ Theano (default) / TensorFlow (2016~) / MXNet (2017~) / CNTK (WIP)
§ ETC
§ Paddle, Chainer, DL4J…
TensorFlow: Summary
§ Statistics § TensorFlow Serving
§ More than 24000 commits since Dec. 2015 § Enables easier inference / model serving
§ More than 1140 committers § XLA compiler (1.0~)
§ More than 24000 forks for last 12 months § Support various environments / speedups
§ Dominates Bootstrap! (15000)
§ More than 6400 TensorFlow-related § Keras API Support (1.2~)
repository created on GitHub § High-level programming API
§ Keras-compatible API
§ Current § Eager Execution (1.4~)
§ Complete ML model prototyping § Interactive mode of TensorFlow
§ Distributed training § Treat TensorFlow python code as real
§ CPU / GPU / TPU / Mobile support python code
https://www.infoworld.com/article/3233283/javascript/at-github-javascript-rules-in-usage-tensorflow-leads-in-forks.html
TensorFlow: Summary
2016 § TensorFlow Serving
⏤ TFLearn (contrib)
⏤ SyntaxNet § Enables easier inference / model serving
⏤ Multi GPU support § XLA compiler (1.0~)
⏤ SKLearn (contrib)
⏤ Distributed TensorFlow
§ Support various environments / speedups
⏤ OpenAL w/ OpenCompute
§ Keras API Support (1.2~)
⏤ TensorFlow Serving
⏤ TensorFlow Slim § High-level programming API
⏤ Mobile TensorFlow § Keras-compatible API
2017
⏤ XLA
§ Eager Execution (1.4~)
⏤ Keras API § Interactive mode of TensorFlow
⏤ DRAGNN § Treat TensorFlow python code as real
⏤ TensorFlow TimeSeries python code
⏤ TensorFlow Datasets
⏤ Eager Execution
⏤ TensorFlow Lite
How TensorFlow works
§ CPU
§ Multiprocessor
§ AVX-based acceleration
§ GPU part in chip
§ OpenMP
§ GPU
§ CUDA (NVidia) ➜ cuDNN
§ OpenCL (AMD) ➜ ComputeCPP /
ROCm
§ TPU (1st, 2nd gen.)
§ ASIC for accelerating matrix
calculation
§ In-house development by Google
https://www.tensorflow.org/get_started/graph_viz
How TensorFlow works
§ Python but not Python
§ Python API is default API for
TensorFlow
§ However, TF core is written in C++,
with cuDNN library (for GPU
acceleration)
§ Computation Graph
§ User TF code is not a code
§ it is a configuration to generate
computation graph
§ Session
§ Creates a computation graph and
run the training using C++ core
§ Tedious debug process
How TensorFlow works
§ Features
§ Model building
§ Model versioning
§ Model saving / loading
§ Online inference support with RPC
Keras-compatible API for TensorFlow
§ Keras ( https://keras.io )
§ High-level API
§ Focus on user experience
§ “Deep learning accessible to everyone”
§ History
§ Announced at Feb. 2017
§ Bundled as an contribution package from TF 1.2
§ Official core package since 1.4
§ Characteristics
§ “Simplified workflow for TensorFlow users, more powerful features to Keras users”
§ Most Keras code can be used on TensorFlow (with keras. to tf.keras.)
§ Can mix Keras code with TensorFlow codes
TensorFlow Datasets
§ New way to generate data pipeline
§ Dataset classes
§ TextLineDataset
§ TFRecordDataset
§ FixedLengthRecordDataset
§ Iterator
Example: Decoding and resizing image data
# Reads an image from a file, decodes it into a dense tensor, and resizes it
# to a fixed shape.
def _parse_function(filename, label):
image_string = tf.read_file(filename)
image_decoded = tf.image.decode_image(image_string)
image_resized = tf.image.resize_images(image_decoded, [28, 28])
return image_resized, label
# A vector of filenames.
filenames = tf.constant(["/var/data/image1.jpg", "/var/data/image2.jpg", ...])
print(m) print(m)
# Tensor("MatMul:0", shape=(1, 1), # tf.Tensor([[4.]], dtype=float32,
dtype=float32) shape=(1,1))
x = tf.gather([0, 1, 2], 7)
# Outputs
tf.Tensor(3, dtype=int32)
a = tf.constant(6) tf.Tensor(10, dtype=int32)
while not tf.equal(a, 1): tf.Tensor(5, dtype=int32)
if tf.equal(a % 2, 0): tf.Tensor(16, dtype=int32)
a = a / 2 tf.Tensor(8, dtype=int32)
else: tf.Tensor(4, dtype=int32)
a = 3 * a + 1 tf.Tensor(2, dtype=int32)
print(a) tf.Tensor(1, dtype=int32)
Eager execution: Gradients
def square(x):
return tf.multiply(x, x) # Or x * x
grad = tfe.gradients_function(square)
def square(x):
return tf.multiply(x, x) # Or x * x
grad = tfe.gradients_function(square)
gradgrad = tfe.gradients_function(lambda x: grad(x)[0])
def log1pexp(x):
return tf.log(1 + tf.exp(x))
grad_log1pexp = tfe.gradients_function(log1pexp)
print(grad_log1pexp(0.))
def log1pexp(x):
return tf.log(1 + tf.exp(x))
grad_log1pexp = tfe.gradients_function(log1pexp)
print(grad_log1pexp(100.))
with tf.device(“/gpu:0”):
x = tf.random_uniform([10, 10])
y = tf.matmul(x, x)
# x and y reside in GPU memory
Eager execution: Building Models
grad_fn = tfe.implicit_gradients(loss)
Interactive
mode
X X X O X X O X X
Multi-CPU
(NUMA)
O O X X O O O O O
Multi-CPU
(Cluster)
O O O X O O X O O
?
Multi-GPU (manual
(single node)
O O O X O O O O
multi-
batch)
Multi-GPU
(Cluster)
O O O X O O X O O
TensorFlow Lite
§ TensorFlow Lite: Embedded
TensorFlow
§ No additional environment installation
required
§ OS level hardware acceleration
§ Leverages Android NN
+ =
§ Easy personalization : server-side training
Market: User-side deep learning services
§ Inference with trained models
§ Does not require heavy calculation
§ e.g. ARMv7 with ~512MB / 1GB RAM
§ IoT + ML
§ Locality : Home (per room), Car, Office, etc.
§ E.g. Smart home resource management systems
Market: Deep Learning service for everyone
§ Digital assistants War
§ Digital assistant (with sprakers): Gateway of deep learning based services
§ Context extraction + inference + features
§ Why?
§ 2017
§ General goal of new versions: user-friendly syntax
§ Rise of Keras, PyTorch leads TensorFlow Eager execution
Server-side machine learning
§ Machine learning workload characteristics
§ Training
§ Requires ultra-heavy computation resources
§ Need to feed big, indexed data
§ OR, (reinforcement learning) need pair model / training
environment to give feedbacks
§ Serving
§ Requires (relatively) light resources:
§ Low CPU cost
§ Middle memory capacity (to load NeuralNet)
TensorFlow: Multiverse
§ TensorFlow AMD GPU acceleration
§ OpenCL with ComputeCPP (Feb. 2017)
§ Accelerates c++ codes (codeplay)
§ Khronos support / SYCL standard
§ Still in early stage
§ Only supports Linux
§ Privacy issues
§ Increasing privacy information
§ ETC
§ Lead the network cost reduction
Hand-held machine learning: How?
§ Apple’s approach
§ Keeping user privacy with Differential Privacy
§ Gather Anonymized user data
§ User-specific machine learning models: keep them in the phone
§ e.g. Photo face detection / voice recognition / smart keyboard
§ Core ML (iOS 11)
§ Support Machine Learning model as function (.mlmodel format)
§ Google’s approach
§ Ultra-large scale server side training using TPU (2nd gen.)
§ Mobile: Handles data compression and feature extraction (to reduce traffic)
§ On the mobile:
§ Android NeuralNet API (Android O)
§ TensorFlow Lite on Android (Android O)
https://backchannel.com/an-exclusive-look-at-how-ai-and-machine-learning-work-at-apple-8dbfb131932b
Hand-held machine learning: How?
§ Train on server, Serve on smartphone
§ Enough to serve pre-trained models on smartphones
§ Working together
§ Feature extraction / compression / preprocessing ‒ Mobile side
§ Machine Learning model training / updating / streaming advanced models ‒ Server side
Hand-held machine learning: How?
§ TensorFlow
§ Supports both Android and iOS
§ XCode and Android Studio
§ XLA compiler framework since TensorFlow 1.0:
§ Will support diverse languages / environments
§ Also, optimizing for smartphones and tablets
§ MobileNet (Apr. 2017)
§ Efficient Convolutional Neural Networks for Mobile Vision Applications
§ TensorFlow Lite (Nov. 2017): development focus
§ Built-in operators for both quantized models (int (8bit) / fixed point) and floating point models
(FP10, FP16)
§ Support for embedded GPUs / ASICs
Browser-side machine learning
§ Machine Learning without hassle
§ Ingredients for machine learning: Computation, Data, Algorithm
§ XLA: provides binary-code level optimization for various environment
§ Do we have cross-platform computation environment?
§ Java?
§ Browser!
§ Eager execution
§ TensorFlow Lite
§ Flow goes to
§ More user-friendly toolkits / frameworks
§ API-based / personalized
§ User-side inference / Hand-held ML
§ Convertible Machine Learning Model formats
End!
Thank you for listening
Lablup Inc. https://www.lablup.ai
Backend.AI https://backend.ai
Backend.AI Cloud https://cloud.backend.ai
CodeOnWeb Service https://www.codeonweb.com
Github repository https://github.com/lablup