SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
A Tale of Three Deep
Learning Frameworks:
TensorFlow, Keras, and
PyTorch
Brooke Wenig
Jules S. Damji
Spark + AI Summit, London 4October 2018
About Us . . .
Machine LearningPractice Lead @ Databricks
Data Science @ Splunk & MyFitnessPal
MS Machine Learning(UCLA)
Fluentin Chinese
https://www.linkedin.com/in/brookewenig/
Brooke WenigJules S. Damji
Apache Spark Developer& Community
Advocate @Databricks
Program Chair Spark + AI Summit
Software engineering @Sun Microsystems,
Netscape, @Home, VeriSign, Scalix, Centrify,
LoudCloud/Opsware, ProQuest
https://www.linkedin.com/in/dmatrix
@2twitme
Agenda for Today’s Talk
• What’s Deep Learning and Why?
• Short Survey of 3 DL Frameworks
• TensorFlow
• Keras
• PyTorch
• Training Options
• Single Node
• Distributed
• Q&A
What is Deep Learning?
“Composing representations of data in a
hierarchical manner”
Why Deep Learning?
Applications
Source : MIT
Zoo of DL Frameworks: Which One?
DPL
Survey of Three Deep
Learning Frameworks
What’s TensorFlow?
• Open source from Google, 2015
• Current v1.12 API
• 2.0 Coming Soon... :)
• Declarative Toolkit
• Fast: Backend C/C++
• Data flow graphs
• Nodes are functions/operators
• Edges are input or data (tensors)
• Lazy execution
• Eager execution (1.7)
TensorFlow Key API Concepts
• Constants
• Variables
• Placeholders
• Operations
• Sessions
• Tensors
• Graphs
•
x = tf.constants (42, name= ‘x’)
w = tf.Variable(1.34,name=’w’)
input= tf.Placeholder(“float”)
c = tf.add(x, w); m = tf.matmul(a, b) ...
with tf.Session([URI]) as sess:
1, [1, 2], [[2, 3], [4, 5]] ...
g = tf.Graph(“my_graph”)
withg.as_default():
c = tf.add(x,w)
m= tf.matmul(a, b)
TensorFlow Code
import tensorflow as tf
a = tf.placeholder(tf.float32, shape=(2,1))
b = tf.placeholder(tf.float32, shape=(1,2))
c = tf.matmul(a, b)
sess = tf.Session()
print(sess.run(c, {a: [[1],[2]], b:[[3,4]]}))
[[3. 4.] [6. 8.]]
Create a TF Session
Run the session, with input parameters
for place holders ‘a’ & ’b’
‘c’ as an operation won’t to run until
sess.run() Lazily evaluated.
TF matmul matrix operation
TF session output
Create TF placeholder types, a & b
Define their input shape as tensors
TensorFlow Code: MNIST
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
# Create the model
x = tf.placeholder(tf.float32, [None, 784])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
y = tf.matmul(x, W) + b
y_ = tf.placeholder(tf.int64, [None])
...
# Define loss and optimizer
cross_entropy = tf.losses.sparse_softmax_cross_entropy(labels=y_, logits=y)
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
#create session, train, and evaluate
sess = tf.InteractiveSession()
tf.global_variables_initializer().run()
# Train
for _ in range(1000):
batch_xs, batch_ys = mnist.train.next_batch(100)
sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})
# Test trained model
correct_prediction = tf.equal(tf.argmax(y, 1), y_)
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
...
print(sess.run(accuracy, feed_dict={
x: mnist.test.images,
y_: mnist.test.labels
}))
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/mnist/mnist_softmax.py
Use tf input_data modules for MNIST
TF placeholders & variables
Define our model
TF variable for predicted value y’
Define our loss function: cross_entropy
Use Gradient Descent Optimizer
Train or evaluate the model
TensorFlow Programming Stack
CPU GPU Android iOS …TPU
Use canned estimators
Build models
Keras	
Models
Why TensorFlow: Community
AF
AF
• 105K+ stars!
• 11+M downloads
• Popular open-source code
• TensorFlow Hub & Blog
○ Code Examples &
Tutorials!
○ Learn + share from
others
Why TensorFlow: Tools
AF
AF
Deploy + Serve Models
TFX
Visualize Tensors flow
TensorFlow: We Get it … So What?
• Steep learning curve, but powerful!!
• Low-level APIs, butoffers control!!
• Expert in Machine Learning, justlearn!!
• Yet, high-level Estimators help, you bet!!
• Yeah, TensorFlow 2.0, ease-of-use,eagerexecution!
• Better, Keras integration helps, indeed!!
What’s Keras?
• Open source Python Library APIs for Deep Learning
• Current v2.2.2 APIs François Chollet (Google)
• APIs : with TensorFlow, CNTK and Theano Backends
• Easy to UseHigh-Level DeclarativeAPIs!
• Build layers
– Great for Neural Network Applications
– CNN
– RNN & LSTM
• Fast Experimentation,Modular & Extensible!
Keras Programming Stack
CPU GPU Android iOS …TPU
Use canned estimators
Specific
Runtime
Backend Impl
models
Python	Keras	API	
TF-Keras Theano-Keras CNTK
TensorFlow	
Workflow
.....
Why Keras?
• Focuses on Developer Experience
• Popular & Broader Community
• Supports multiple backends
• Modularity
• Sequential
• Functional
model = Sequential()
model.add(Dense(32, input_dim=784))
model.add(Activation('relu'))
model.add(Dense, 32, activation=’softmax’)
...
Keras Code: MNIST
from keras import models
from keras import layers
mnist = tf.keras.datasets.mnist
(train_images, train_labels),(test_images, test_labels)=
prepare_data(mnist.load_data())
network= models.Sequential()
network.add(layers.Dense(512, activation=‘relu’,
input_shape(28 * 28,)))
network.add(layers.Dense(10, activation=‘softmax’))
network.compile(optimizer=’rmsprop',
loss='categorical_crossentropy',
metrics=['accuracy'])
network.fit(train_images, train_labels, epochs=5,
batch_size=128 )
results = network.evaluate(test_images, test_labels)
Set up code & use dataset
Define Network
Fit Network
Compile Network
Evaluate Network
predictions = network.predict(new_images) Make Predictions
Repeatable
Another a Simple Network Model:Which code is easier to read?
What is PyTorch?
• Open source from Facebook, 2017
– v1.0 dev release
• Primarily a Python Package
• Tensor Computations
– Torch.tensor -> CPU, GPU/CUDA
• Dynamic NN: Tape-based Autograd
• Graph Based Dynamic Computations
• Imperative Toolkit
PyTorch Programming Stack
Python API
Auto Differentiation
Engine
Numpy Library
(GPU Support )
Gradient Based
Optimized Package
Utilities
(Data, Text, Video..)
Deep Learning &
Reinforcement
Learning
Numpy Alternative
Ndarray <->torch.Tensor
Optimized: Adam,
Adamax, RMSProp,
SGD, LBFGS ...
Data loading: SciPy,
SpaCy, OpenCV,
PIL, torchvision
CPU CPU GPU GPU...
Why PyTorch?
• Imperative Experience
– Rapid Prototyping for Research
– Easy Debugging & TBX
• Quick Ramp-up time
• Decent Docs & Community
– 275K Downloads
– 1900 Community Repos
– 13+K Blogs Posts
• Pythonic!
PyTorch Key API Concepts
• Variables & Autograd
• Torch Tensors
• Operations
•
from torch import Variable
x = Variable(torch.Tensor([2]),requires_grad=True)
y = 5*x**4 + 3*x**3 + 7*x**2 + 9*x - 5
y.backward() #compute gradient and backpropagate
x.grad
#different kinds of Torch Tensors
x = torch.rand(5, 3);
y = torch.rand(5, 3)
t = torch.tensor([5.5, 3])
n = torch.tensor(np.array([[1, 2, 3], [4, 5, 6]]))
#operations or element-wise operations
a = (x + y)
m = (x * y)
if torch.cuda.is_available():
x = x.cuda()
y = y.cuda()
torch.add(x, y, out=result)
print(a, m, out)
PyTorch Rhythm ...
Design Model with
Autograd Variables
Construct Loss and
Optimizer
Training
Cycle
1
.
2
Design a model using PyTorch Autograd
Variables
Construct a loss function and optimizer with
PyTorch APIs
Train your model: forward, backward, and
update steps
1. 1
1
3
.
2
.
2
3.
2.
PyTorch Rhythm : Linear Regression
https://www.youtube.com/watch?v=113b7O3mabY (Sung Kim)
Training Options
Options
1) Train on single node
2) Train on single node, distributed inference
3) Distributed training
Horovod
● Created by Alexander Sergeev of Uber, open-sourced in 2017
● Simplifies distributed neural network training
● Supports TensorFlow, Keras, and PyTorch
Classical Parameter Server
All-Reduce
Minimal Code Change
TensorFlow, Keras, or
PyTorch?
Takeaways: Gaining Momentum...
Keras
TensorFlow
PyTorch
TensorFlow Keras
Takeaways: When to Use TF, Keras or PyTorch
PyTorch
• Low-level APIs & Control
• Model Serving
• Supports multiple
languages
• High-level APIs
• MultipleBackends
• LovePython
• Rapid Experimentation
• Pythonic!
• Imperative
Programming
• RapidExperimentation
Databricks Runtime for Machine Learning
Ready to use clusters with built-in ML Frameworks
includingTensorFlow, Keras, Horovod, andmore
Horovod Estimator
for simplifieddistributedtrainingon TensorFlowwith HorovodusingApache Spark on Databricks
GPU support
on AWS (P2/P3) andAzure (NC/NC-v3) instancesnow supported!
Resources & BooksBlogposts Talk, & webinars (http://databricks.com/blog)
• GPU acceleration in Databricks
• Deep Learning and ApacheSpark
• fast.ai
• TensorFlowTutorials
• TensorFlowDev Summit
• Keras/TensorFlowTutorials
• PyTorch Docs & Tutorials
• Talk-1from Soumith Chintala
• Talk-2from Soumith Chintala
• MLflow.org
Docs for Deep Learning on Databricks (http://docs.databricks.com)
• Databricks RuntimeML
• HorovodEstimator
Thank You!
Questions?
brooke@databricks.com
jules@databricks.com (@2twitme)

Weitere ähnliche Inhalte

Was ist angesagt?

Backpropagation in Convolutional Neural Network
Backpropagation in Convolutional Neural NetworkBackpropagation in Convolutional Neural Network
Backpropagation in Convolutional Neural Network
Hiroshi Kuwajima
 

Was ist angesagt? (20)

Mastering Your Customer Data on Apache Spark by Elliott Cordo
Mastering Your Customer Data on Apache Spark by Elliott CordoMastering Your Customer Data on Apache Spark by Elliott Cordo
Mastering Your Customer Data on Apache Spark by Elliott Cordo
 
Vector database
Vector databaseVector database
Vector database
 
Feature Engineering
Feature Engineering Feature Engineering
Feature Engineering
 
Lstm
LstmLstm
Lstm
 
Introduction to Recurrent Neural Network
Introduction to Recurrent Neural NetworkIntroduction to Recurrent Neural Network
Introduction to Recurrent Neural Network
 
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
 
Machine Learning Model Deployment: Strategy to Implementation
Machine Learning Model Deployment: Strategy to ImplementationMachine Learning Model Deployment: Strategy to Implementation
Machine Learning Model Deployment: Strategy to Implementation
 
MLflow: Infrastructure for a Complete Machine Learning Life Cycle
MLflow: Infrastructure for a Complete Machine Learning Life CycleMLflow: Infrastructure for a Complete Machine Learning Life Cycle
MLflow: Infrastructure for a Complete Machine Learning Life Cycle
 
Deploying Machine Learning Models to Production
Deploying Machine Learning Models to ProductionDeploying Machine Learning Models to Production
Deploying Machine Learning Models to Production
 
Anomaly Detection - Real World Scenarios, Approaches and Live Implementation
Anomaly Detection - Real World Scenarios, Approaches and Live ImplementationAnomaly Detection - Real World Scenarios, Approaches and Live Implementation
Anomaly Detection - Real World Scenarios, Approaches and Live Implementation
 
Training Neural Networks
Training Neural NetworksTraining Neural Networks
Training Neural Networks
 
Backpropagation in Convolutional Neural Network
Backpropagation in Convolutional Neural NetworkBackpropagation in Convolutional Neural Network
Backpropagation in Convolutional Neural Network
 
Calibrated Recommendations
Calibrated RecommendationsCalibrated Recommendations
Calibrated Recommendations
 
Model selection and cross validation techniques
Model selection and cross validation techniquesModel selection and cross validation techniques
Model selection and cross validation techniques
 
Deep learning
Deep learningDeep learning
Deep learning
 
Machine Learning Deep Learning AI and Data Science
Machine Learning Deep Learning AI and Data Science Machine Learning Deep Learning AI and Data Science
Machine Learning Deep Learning AI and Data Science
 
Explainable Machine Learning (Explainable ML)
Explainable Machine Learning (Explainable ML)Explainable Machine Learning (Explainable ML)
Explainable Machine Learning (Explainable ML)
 
Introduction of Deep Reinforcement Learning
Introduction of Deep Reinforcement LearningIntroduction of Deep Reinforcement Learning
Introduction of Deep Reinforcement Learning
 
Feature Engineering for ML - Dmitry Larko, H2O.ai
Feature Engineering for ML - Dmitry Larko, H2O.aiFeature Engineering for ML - Dmitry Larko, H2O.ai
Feature Engineering for ML - Dmitry Larko, H2O.ai
 
Best Python Libraries For Data Science & Machine Learning | Edureka
Best Python Libraries For Data Science & Machine Learning | EdurekaBest Python Libraries For Data Science & Machine Learning | Edureka
Best Python Libraries For Data Science & Machine Learning | Edureka
 

Ähnlich wie A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with Brooke Wenig and Jules Damji

Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
Chris Fregly
 

Ähnlich wie A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with Brooke Wenig and Jules Damji (20)

Automate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scala
Automate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scalaAutomate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scala
Automate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scala
 
Language translation with Deep Learning (RNN) with TensorFlow
Language translation with Deep Learning (RNN) with TensorFlowLanguage translation with Deep Learning (RNN) with TensorFlow
Language translation with Deep Learning (RNN) with TensorFlow
 
Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117
 
Simone Scardapane - Bring your neural networks to the browser with TF.js! - C...
Simone Scardapane - Bring your neural networks to the browser with TF.js! - C...Simone Scardapane - Bring your neural networks to the browser with TF.js! - C...
Simone Scardapane - Bring your neural networks to the browser with TF.js! - C...
 
Machine learning with py torch
Machine learning with py torchMachine learning with py torch
Machine learning with py torch
 
NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...
NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...
NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...
 
Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
 
slide-keras-tf.pptx
slide-keras-tf.pptxslide-keras-tf.pptx
slide-keras-tf.pptx
 
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
 
Bring your neural networks to the browser with TF.js - Simone Scardapane
Bring your neural networks to the browser with TF.js - Simone ScardapaneBring your neural networks to the browser with TF.js - Simone Scardapane
Bring your neural networks to the browser with TF.js - Simone Scardapane
 
Anirudh Koul. 30 Golden Rules of Deep Learning Performance
Anirudh Koul. 30 Golden Rules of Deep Learning PerformanceAnirudh Koul. 30 Golden Rules of Deep Learning Performance
Anirudh Koul. 30 Golden Rules of Deep Learning Performance
 
Spark Summit EU talk by Tim Hunter
Spark Summit EU talk by Tim HunterSpark Summit EU talk by Tim Hunter
Spark Summit EU talk by Tim Hunter
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
 
Meetup tensorframes
Meetup tensorframesMeetup tensorframes
Meetup tensorframes
 
Google Big Data Expo
Google Big Data ExpoGoogle Big Data Expo
Google Big Data Expo
 
A Tour of Tensorflow's APIs
A Tour of Tensorflow's APIsA Tour of Tensorflow's APIs
A Tour of Tensorflow's APIs
 
Machine Learning and Go. Go!
Machine Learning and Go. Go!Machine Learning and Go. Go!
Machine Learning and Go. Go!
 
OpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon ValleyOpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon Valley
 
Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017
Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017
Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017
 
Standardizing on a single N-dimensional array API for Python
Standardizing on a single N-dimensional array API for PythonStandardizing on a single N-dimensional array API for Python
Standardizing on a single N-dimensional array API for Python
 

Mehr von Databricks

Democratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized PlatformDemocratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized Platform
Databricks
 
Stage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI IntegrationStage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI Integration
Databricks
 
Simplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorchSimplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorch
Databricks
 
Raven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction QueriesRaven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction Queries
Databricks
 
Processing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache SparkProcessing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache Spark
Databricks
 

Mehr von Databricks (20)

DW Migration Webinar-March 2022.pptx
DW Migration Webinar-March 2022.pptxDW Migration Webinar-March 2022.pptx
DW Migration Webinar-March 2022.pptx
 
Data Lakehouse Symposium | Day 1 | Part 1
Data Lakehouse Symposium | Day 1 | Part 1Data Lakehouse Symposium | Day 1 | Part 1
Data Lakehouse Symposium | Day 1 | Part 1
 
Data Lakehouse Symposium | Day 1 | Part 2
Data Lakehouse Symposium | Day 1 | Part 2Data Lakehouse Symposium | Day 1 | Part 2
Data Lakehouse Symposium | Day 1 | Part 2
 
Data Lakehouse Symposium | Day 2
Data Lakehouse Symposium | Day 2Data Lakehouse Symposium | Day 2
Data Lakehouse Symposium | Day 2
 
Data Lakehouse Symposium | Day 4
Data Lakehouse Symposium | Day 4Data Lakehouse Symposium | Day 4
Data Lakehouse Symposium | Day 4
 
5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop
5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop
5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop
 
Democratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized PlatformDemocratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized Platform
 
Learn to Use Databricks for Data Science
Learn to Use Databricks for Data ScienceLearn to Use Databricks for Data Science
Learn to Use Databricks for Data Science
 
Why APM Is Not the Same As ML Monitoring
Why APM Is Not the Same As ML MonitoringWhy APM Is Not the Same As ML Monitoring
Why APM Is Not the Same As ML Monitoring
 
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch FixThe Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
 
Stage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI IntegrationStage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI Integration
 
Simplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorchSimplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorch
 
Scaling your Data Pipelines with Apache Spark on Kubernetes
Scaling your Data Pipelines with Apache Spark on KubernetesScaling your Data Pipelines with Apache Spark on Kubernetes
Scaling your Data Pipelines with Apache Spark on Kubernetes
 
Scaling and Unifying SciKit Learn and Apache Spark Pipelines
Scaling and Unifying SciKit Learn and Apache Spark PipelinesScaling and Unifying SciKit Learn and Apache Spark Pipelines
Scaling and Unifying SciKit Learn and Apache Spark Pipelines
 
Sawtooth Windows for Feature Aggregations
Sawtooth Windows for Feature AggregationsSawtooth Windows for Feature Aggregations
Sawtooth Windows for Feature Aggregations
 
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen SinkRedis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
 
Re-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and SparkRe-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and Spark
 
Raven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction QueriesRaven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction Queries
 
Processing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache SparkProcessing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache Spark
 
Massive Data Processing in Adobe Using Delta Lake
Massive Data Processing in Adobe Using Delta LakeMassive Data Processing in Adobe Using Delta Lake
Massive Data Processing in Adobe Using Delta Lake
 

Kürzlich hochgeladen

In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
ahmedjiabur940
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
gajnagarg
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Bertram Ludäscher
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
nirzagarg
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
HyderabadDolls
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
nirzagarg
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
gajnagarg
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
nirzagarg
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
vexqp
 
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
nirzagarg
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
gajnagarg
 

Kürzlich hochgeladen (20)

In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubai
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
 
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
 

A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with Brooke Wenig and Jules Damji

  • 1. A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, and PyTorch Brooke Wenig Jules S. Damji Spark + AI Summit, London 4October 2018
  • 2. About Us . . . Machine LearningPractice Lead @ Databricks Data Science @ Splunk & MyFitnessPal MS Machine Learning(UCLA) Fluentin Chinese https://www.linkedin.com/in/brookewenig/ Brooke WenigJules S. Damji Apache Spark Developer& Community Advocate @Databricks Program Chair Spark + AI Summit Software engineering @Sun Microsystems, Netscape, @Home, VeriSign, Scalix, Centrify, LoudCloud/Opsware, ProQuest https://www.linkedin.com/in/dmatrix @2twitme
  • 3. Agenda for Today’s Talk • What’s Deep Learning and Why? • Short Survey of 3 DL Frameworks • TensorFlow • Keras • PyTorch • Training Options • Single Node • Distributed • Q&A
  • 4. What is Deep Learning? “Composing representations of data in a hierarchical manner”
  • 7. Zoo of DL Frameworks: Which One? DPL
  • 8. Survey of Three Deep Learning Frameworks
  • 9. What’s TensorFlow? • Open source from Google, 2015 • Current v1.12 API • 2.0 Coming Soon... :) • Declarative Toolkit • Fast: Backend C/C++ • Data flow graphs • Nodes are functions/operators • Edges are input or data (tensors) • Lazy execution • Eager execution (1.7)
  • 10. TensorFlow Key API Concepts • Constants • Variables • Placeholders • Operations • Sessions • Tensors • Graphs • x = tf.constants (42, name= ‘x’) w = tf.Variable(1.34,name=’w’) input= tf.Placeholder(“float”) c = tf.add(x, w); m = tf.matmul(a, b) ... with tf.Session([URI]) as sess: 1, [1, 2], [[2, 3], [4, 5]] ... g = tf.Graph(“my_graph”) withg.as_default(): c = tf.add(x,w) m= tf.matmul(a, b)
  • 11. TensorFlow Code import tensorflow as tf a = tf.placeholder(tf.float32, shape=(2,1)) b = tf.placeholder(tf.float32, shape=(1,2)) c = tf.matmul(a, b) sess = tf.Session() print(sess.run(c, {a: [[1],[2]], b:[[3,4]]})) [[3. 4.] [6. 8.]] Create a TF Session Run the session, with input parameters for place holders ‘a’ & ’b’ ‘c’ as an operation won’t to run until sess.run() Lazily evaluated. TF matmul matrix operation TF session output Create TF placeholder types, a & b Define their input shape as tensors
  • 12. TensorFlow Code: MNIST import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) # Create the model x = tf.placeholder(tf.float32, [None, 784]) W = tf.Variable(tf.zeros([784, 10])) b = tf.Variable(tf.zeros([10])) y = tf.matmul(x, W) + b y_ = tf.placeholder(tf.int64, [None]) ... # Define loss and optimizer cross_entropy = tf.losses.sparse_softmax_cross_entropy(labels=y_, logits=y) train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy) #create session, train, and evaluate sess = tf.InteractiveSession() tf.global_variables_initializer().run() # Train for _ in range(1000): batch_xs, batch_ys = mnist.train.next_batch(100) sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys}) # Test trained model correct_prediction = tf.equal(tf.argmax(y, 1), y_) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) ... print(sess.run(accuracy, feed_dict={ x: mnist.test.images, y_: mnist.test.labels })) https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/mnist/mnist_softmax.py Use tf input_data modules for MNIST TF placeholders & variables Define our model TF variable for predicted value y’ Define our loss function: cross_entropy Use Gradient Descent Optimizer Train or evaluate the model
  • 13. TensorFlow Programming Stack CPU GPU Android iOS …TPU Use canned estimators Build models Keras Models
  • 14. Why TensorFlow: Community AF AF • 105K+ stars! • 11+M downloads • Popular open-source code • TensorFlow Hub & Blog ○ Code Examples & Tutorials! ○ Learn + share from others
  • 15. Why TensorFlow: Tools AF AF Deploy + Serve Models TFX Visualize Tensors flow
  • 16. TensorFlow: We Get it … So What? • Steep learning curve, but powerful!! • Low-level APIs, butoffers control!! • Expert in Machine Learning, justlearn!! • Yet, high-level Estimators help, you bet!! • Yeah, TensorFlow 2.0, ease-of-use,eagerexecution! • Better, Keras integration helps, indeed!!
  • 17. What’s Keras? • Open source Python Library APIs for Deep Learning • Current v2.2.2 APIs François Chollet (Google) • APIs : with TensorFlow, CNTK and Theano Backends • Easy to UseHigh-Level DeclarativeAPIs! • Build layers – Great for Neural Network Applications – CNN – RNN & LSTM • Fast Experimentation,Modular & Extensible!
  • 18. Keras Programming Stack CPU GPU Android iOS …TPU Use canned estimators Specific Runtime Backend Impl models Python Keras API TF-Keras Theano-Keras CNTK TensorFlow Workflow .....
  • 19. Why Keras? • Focuses on Developer Experience • Popular & Broader Community • Supports multiple backends • Modularity • Sequential • Functional model = Sequential() model.add(Dense(32, input_dim=784)) model.add(Activation('relu')) model.add(Dense, 32, activation=’softmax’) ...
  • 20. Keras Code: MNIST from keras import models from keras import layers mnist = tf.keras.datasets.mnist (train_images, train_labels),(test_images, test_labels)= prepare_data(mnist.load_data()) network= models.Sequential() network.add(layers.Dense(512, activation=‘relu’, input_shape(28 * 28,))) network.add(layers.Dense(10, activation=‘softmax’)) network.compile(optimizer=’rmsprop', loss='categorical_crossentropy', metrics=['accuracy']) network.fit(train_images, train_labels, epochs=5, batch_size=128 ) results = network.evaluate(test_images, test_labels) Set up code & use dataset Define Network Fit Network Compile Network Evaluate Network predictions = network.predict(new_images) Make Predictions Repeatable
  • 21. Another a Simple Network Model:Which code is easier to read?
  • 22. What is PyTorch? • Open source from Facebook, 2017 – v1.0 dev release • Primarily a Python Package • Tensor Computations – Torch.tensor -> CPU, GPU/CUDA • Dynamic NN: Tape-based Autograd • Graph Based Dynamic Computations • Imperative Toolkit
  • 23. PyTorch Programming Stack Python API Auto Differentiation Engine Numpy Library (GPU Support ) Gradient Based Optimized Package Utilities (Data, Text, Video..) Deep Learning & Reinforcement Learning Numpy Alternative Ndarray <->torch.Tensor Optimized: Adam, Adamax, RMSProp, SGD, LBFGS ... Data loading: SciPy, SpaCy, OpenCV, PIL, torchvision CPU CPU GPU GPU...
  • 24. Why PyTorch? • Imperative Experience – Rapid Prototyping for Research – Easy Debugging & TBX • Quick Ramp-up time • Decent Docs & Community – 275K Downloads – 1900 Community Repos – 13+K Blogs Posts • Pythonic!
  • 25. PyTorch Key API Concepts • Variables & Autograd • Torch Tensors • Operations • from torch import Variable x = Variable(torch.Tensor([2]),requires_grad=True) y = 5*x**4 + 3*x**3 + 7*x**2 + 9*x - 5 y.backward() #compute gradient and backpropagate x.grad #different kinds of Torch Tensors x = torch.rand(5, 3); y = torch.rand(5, 3) t = torch.tensor([5.5, 3]) n = torch.tensor(np.array([[1, 2, 3], [4, 5, 6]])) #operations or element-wise operations a = (x + y) m = (x * y) if torch.cuda.is_available(): x = x.cuda() y = y.cuda() torch.add(x, y, out=result) print(a, m, out)
  • 26. PyTorch Rhythm ... Design Model with Autograd Variables Construct Loss and Optimizer Training Cycle 1 . 2 Design a model using PyTorch Autograd Variables Construct a loss function and optimizer with PyTorch APIs Train your model: forward, backward, and update steps 1. 1 1 3 . 2 . 2 3. 2.
  • 27. PyTorch Rhythm : Linear Regression https://www.youtube.com/watch?v=113b7O3mabY (Sung Kim)
  • 29. Options 1) Train on single node 2) Train on single node, distributed inference 3) Distributed training
  • 30. Horovod ● Created by Alexander Sergeev of Uber, open-sourced in 2017 ● Simplifies distributed neural network training ● Supports TensorFlow, Keras, and PyTorch
  • 36. TensorFlow Keras Takeaways: When to Use TF, Keras or PyTorch PyTorch • Low-level APIs & Control • Model Serving • Supports multiple languages • High-level APIs • MultipleBackends • LovePython • Rapid Experimentation • Pythonic! • Imperative Programming • RapidExperimentation
  • 37. Databricks Runtime for Machine Learning Ready to use clusters with built-in ML Frameworks includingTensorFlow, Keras, Horovod, andmore Horovod Estimator for simplifieddistributedtrainingon TensorFlowwith HorovodusingApache Spark on Databricks GPU support on AWS (P2/P3) andAzure (NC/NC-v3) instancesnow supported!
  • 38. Resources & BooksBlogposts Talk, & webinars (http://databricks.com/blog) • GPU acceleration in Databricks • Deep Learning and ApacheSpark • fast.ai • TensorFlowTutorials • TensorFlowDev Summit • Keras/TensorFlowTutorials • PyTorch Docs & Tutorials • Talk-1from Soumith Chintala • Talk-2from Soumith Chintala • MLflow.org Docs for Deep Learning on Databricks (http://docs.databricks.com) • Databricks RuntimeML • HorovodEstimator