deploying enterprise deep learning masterclass preview - enterprise deep learning

69
Deploying Enterprise Deep Learning Sam Putnam, Enterprise Deep Learning, LLC July 27, 2017 Day 2

Upload: sam-putnam-deep-learning

Post on 23-Jan-2018

160 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Deploying Enterprise Deep Learning

Sam Putnam, Enterprise Deep Learning, LLC

July 27, 2017

Day 2

Page 2: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Deep Learning Made This Video

https://www.extremetech.com/g00/extreme/215170-artificial-neural-networks-are-changing-the-world-what-are-they?i10c.referrer=https%3A%2F%2Fwww.google.com%2F

Preview - Slide Available at deeplearningconf.com

Page 3: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

Deploying Enterprise Deep Learning

And This Song!

Preview - Slide Available at deeplearningconf.com

Page 4: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

And Predicted These Housing Prices!

https://github.com/EnterpriseDeepLearning/housing-prices-wide-and-deep/blob/master/real_estate.ipynb

http://www.mirror.co.uk/news/uk-news/experts-predict-house-prices-could-10724816

Run the Code ->This Afternoon

Page 5: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

OK, so what is Deep Learning?

http://p.migdal.pl/imgs/2017-04-30-learning-deep-learning/deep_learning_meme_keras.png

Preview - Slide Available at deeplearningconf.com

Page 6: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Deep Learning is Neural Networks

http://p.migdal.pl/imgs/2017-04-30-learning-deep-learning/deep_learning_meme_keras.png

Preview - Slide Available at deeplearningconf.com

Page 7: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Well, Artificial Neural Networks. But they are based off of how the brain works.

https://www.extremetech.com/g00/extreme/215170-artificial-neural-networks-are-changing-the-world-what-are-they?i10c.referrer=https%3A%2F%2Fwww.google.com%2F

Preview - Slide Available at deeplearningconf.com

Page 8: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

This is a Neuron: Electrical Signals Are Sent By Axons and Received By Dendrites

http://www.newworldencyclopedia.org/entry/Dendrite

Preview - Slide Available at deeplearningconf.com

Page 9: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

This is a Single Artificial Neuron With Two Inputs and Two Weights

Preview - Slide Available at deeplearningconf.com

Page 10: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

The Artificial Neuron is Also Called a “Perceptron”. It “Perceives” Inputs.

Preview - Slide Available at deeplearningconf.com

Page 11: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

b is the bias, and to activate the neuron:

Page 12: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

Deploying Enterprise Deep Learning

Click Play, Visualize Neuron’s Performance

http://playground.tensorflow.org/

Page 13: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

Deploying Enterprise Deep Learning

Trust Me, When you add more inputs, your decision boundary becomes a “plane”

Preview - Slide Available at deeplearningconf.com

Page 14: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

When you’re talking about Deep Learning you’re talking about Artificial Neural Networks

of Neurons

@edeeplearning

Preview - Slide Available at deeplearningconf.com

Page 15: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

In particular, Deep Learning = Deep Artificial Neural Networks of Neurons

@edeeplearning

Preview - Slide Available at deeplearningconf.com

Page 16: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

This it it - Just more than one layer of neurons between the input and output!

@edeeplearninghttp://blog.christianperone.com/2015/08/convolutional-neural-networks-and-feature-extraction-with-python/

Preview - Slide Available at deeplearningconf.com

Page 17: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

You Tried The Line, Now Add A Hidden Layer To Capture More Complex Data Separations

@edeeplearninghttp://blog.christianperone.com/2015/08/convolutional-neural-networks-and-feature-extraction-with-python/

Page 18: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

This is No Line You Are Tweaking! This Is a More Complex Function

@edeeplearninghttp://blog.christianperone.com/2015/08/convolutional-neural-networks-and-feature-extraction-with-python/

Preview - Slide Available at deeplearningconf.com

Page 19: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

More Neurons + A Deeper Network = More Sophisticated Representations

@edeeplearninghttps://cloud.google.com/blog/big-data/2016/07/understanding-neural-networks-with-tensorflow-playground

Page 20: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Look at the last hidden layer - it is doing a pretty good job separating the data

@edeeplearninghttps://cloud.google.com/blog/big-data/2016/07/understanding-neural-networks-with-tensorflow-playground

Preview - Slide Available at deeplearningconf.com

Page 21: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

This Architecture is called a Feedforward Neural Network

@edeeplearninghttps://cloud.google.com/blog/big-data/2016/07/understanding-neural-networks-with-tensorflow-playground

Preview - Slide Available at deeplearningconf.com

Page 22: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

There’s a Lot Going on Here. Do You Really Want to Change Those Weights One at a Time?

@edeeplearninghttps://cloud.google.com/blog/big-data/2016/07/understanding-neural-networks-with-tensorflow-playground

Preview - Slide Available at deeplearningconf.com

Page 23: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Solution: Gradient Descent - Look How the Lowest Loss (0) Is Sought Out on the Right

@edeeplearninghttps://cloud.google.com/blog/big-data/2016/07/understanding-neural-networks-with-tensorflow-playground

Page 24: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

What other Architectures Are There? Well, what about for Time Series Data

@edeeplearninghttps://deeplearning4j.org/lstm.html

Preview - Slide Available at deeplearningconf.com

Page 25: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Recurrent Neural Networks are Networks with Loops in Them

@edeeplearninghttp://colah.github.io/posts/2015-08-Understanding-LSTMs/

Preview - Slide Available at deeplearningconf.com

Page 26: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Information is passed from one step of the network to the next

@edeeplearninghttp://colah.github.io/posts/2015-08-Understanding-LSTMs/

Preview - Slide Available at deeplearningconf.com

Page 27: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Recurrent Neural Networks (RNNs) Contain A Single Layer (Yellow Box)

@edeeplearninghttp://colah.github.io/posts/2015-08-Understanding-LSTMs/

Page 28: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Recurrent Neural Networks (RNNs) cannot handle long term dependencies

@edeeplearninghttp://colah.github.io/posts/2015-08-Understanding-LSTMs/

Preview - Slide Available at deeplearningconf.com

Page 29: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

LSTM Recurrent Neural Networks (RNNs) Contain Four Layers (Yellow Box)

@edeeplearninghttp://colah.github.io/posts/2015-08-Understanding-LSTMs/

Page 30: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Long Short Term Memory Networks (LSTMs) Can Handle Long Term Dependencies

@edeeplearninghttp://colah.github.io/posts/2015-08-Understanding-LSTMs/

Preview - Slide Available at deeplearningconf.com

Page 31: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

@edeeplearning

Sigmoid Activation Function Scales Your Input Between 0 and 1

http://neuralnetworksanddeeplearning.com/chap4.html

Preview - Slide Available at deeplearningconf.com

Page 32: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sigmoid Activation Function Scales Your Input Between 0 and 1

@edeeplearning

http://neuralnetworksanddeeplearning.com/chap4.html

Preview - Slide Available at deeplearningconf.com

Page 33: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Tanh Activation Function Scales Your Input Between -1 and 1

@edeeplearning

http://neuralnetworksanddeeplearning.com/chap4.html

Preview - Slide Available at deeplearningconf.com

Page 34: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

RELU Activation Function Cuts off Negative Inputs

@edeeplearning

http://neuralnetworksanddeeplearning.com/chap4.html

Preview - Slide Available at deeplearningconf.com

Page 35: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

What About Image Data? For That, Convolutional Neural Networks (Right)

@edeeplearninghttp://cs231n.github.io/convolutional-networks/

Page 36: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Convolution Just Means Picking Out Representative Elements from a Bunch of

Pixels (F represents all the below)

@edeeplearning

Preview - Slide Available at deeplearningconf.com

Page 37: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

This is What Convolution Looks Like, a Little Boring, But Look How It Reduces the Size of

the Data (3x3 on the Right!)

@edeeplearning

Preview - Slide Available at deeplearningconf.com

Page 38: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

So Convolution Is a Mathematical Operation (Using a Weight Filter, Let’s Look!), but Even Simpler is

Max Pooling, just take the Biggest Pixel!

@edeeplearning

Page 39: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

A Pre-Trained Image Recognition Neural Network Looks Like This (Input At Left) - Let’s

Zoom In

@edeeplearninghttps://arxiv.org/pdf/1409.4842.pdf

Preview - Slide Available at deeplearningconf.com

Page 40: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Deep Learning in Production Considerations

Help me find the source for this nice diagram? Lost it :(

Page 41: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Solution - Use What I Know and Am Allowed To Use, i.e. Kaggle, AWS, TF, Jupyter

Help me find the source for this nice diagram? Lost it :(

Preview - Slide Available at deeplearningconf.com

Page 42: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

What I Did - A Real Estate Agent Told Me About His Problem & Pointed Me To The Data

https://www.fortunebuilders.com/how-to-become-a-real-estate-agent/

Preview - Slide Available at deeplearningconf.com

Page 43: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

I Took a Holdout Set of the Data and Left the Rest for Train/Validate

https://www.fortunebuilders.com/how-to-become-a-real-estate-agent/

Page 44: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Started with Feature Selection and then Linear Regression in Good old Excel, WITH the subject matter

expert (the real estate agent). Did Pretty Well.

https://www.youtube.com/watch?v=SQkpLMLoqww

Preview - Slide Available at deeplearningconf.com

Page 45: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Preview - Slide Available at deeplearningconf.com

How Well? 18 percent Mean Error and 26 percent Median Error before Feature Selection using Weighted Importance, Did some thinking:

Page 46: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Feature Importance, for Feature Selection, Often Use After Deep Learning Step, to Gain Interpretability

Page 47: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

https://www.kaggle.com/samdeeplearning/naive-subsample-5-10-city/output

GBM (Boosted Decision Tree) - with Hyperparameter Tweaking - Yields Strong Model for this Problem

Page 48: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

https://www.kaggle.com/samdeeplearning/naive-subsample-0-25-xgb/notebook

Preview - Slide Available at deeplearningconf.com

Starts to Degrade Upon Subsampling only 1/4 of the Trees

Page 49: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Page 50: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Want To See If Neural Network Can Improve Performance

Page 51: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Building off of a preexisting housing prices regression model

https://github.com/EnterpriseDeepLearning/housing-prices-wide-and-deep/blob/master/real_estate.ipynb

Preview - Slide Available at deeplearningconf.com

Page 52: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Set Input Layer (n_hidden_1 is input layer here) to number of features (27)

https://github.com/EnterpriseDeepLearning/housing-prices-wide-and-deep/blob/master/real_estate.ipynb

Preview - Slide Available at deeplearningconf.com

Page 53: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Combining the features right off the bat by using a wide first hidden layer (200 nodes)

https://github.com/EnterpriseDeepLearning/housing-prices-wide-and-deep/blob/master/real_estate.ipynb

Preview - Slide Available at deeplearningconf.com

Page 54: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Set number of classes to 1 for regression problem

https://github.com/EnterpriseDeepLearning/housing-prices-wide-and-deep/blob/master/real_estate.ipynb

Preview - Slide Available at deeplearningconf.com

Page 55: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Multilayer Perceptron = Feedforward Perceptron We Looked At Before

https://github.com/EnterpriseDeepLearning/housing-prices-wide-and-deep/blob/master/real_estate.ipynb

Preview - Slide Available at deeplearningconf.com

Page 56: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

RELU - As Mentioned in Executing Strategies Yesterday, not using negative features/weights

https://github.com/EnterpriseDeepLearning/housing-prices-wide-and-deep/blob/master/real_estate.ipynb

Page 57: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Training - Can tell performance needs tweaking, pretty good on houses 2-6

https://github.com/EnterpriseDeepLearning/housing-prices-wide-and-deep/blob/master/real_estate.ipynb

123456

Estimate on LeftPrediction on Left

Page 58: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Let’s Dive Into the TensorFlow Housing Code

https://www.kaggle.com/samdeeplearning/deep-neural-network-for-starters-r/edit

Preview - Slide Available at deeplearningconf.com

Page 59: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

What Next? Go Deep Learning!

https://www.youtube.com/watch?v=cSKfRcEDGUs&list=PLOU2XLYxmsIIuiBfYad6rFYQU_jL2ryal&index=6

Page 60: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

1) Identify an architecture for your problem

https://www.youtube.com/watch?v=cSKfRcEDGUs&list=PLOU2XLYxmsIIuiBfYad6rFYQU_jL2ryal&index=6

Page 61: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

2) Identify a Framework, Be Willing to Try a New Framework

https://blog.algorithmia.com/deploying-deep-learning-cloud-services/

Page 62: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

3) Build or tailor a model for your application, Don’t be Afraid to Reference Academic Code

https://www.youtube.com/watch?v=cSKfRcEDGUs&list=PLOU2XLYxmsIIuiBfYad6rFYQU_jL2ryal&index=6

Page 63: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

4)Tweak the Parameters for your Model

https://www.youtube.com/watch?v=cSKfRcEDGUs&list=PLOU2XLYxmsIIuiBfYad6rFYQU_jL2ryal&index=6

Page 64: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

5)Train on a (probably, Nvidia, maybe Intel) GPU if need be (for image data, you need it)

https://www.youtube.com/watch?v=2NrgPdGSXhE

Page 65: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

6) Validate, test, check in the real world. Iterate!

https://medium.com/towards-data-science/train-test-split-and-cross-validation-in-python-80b61beca4b6

Preview - Slide Available at deeplearningconf.com

Page 66: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Weekend trial: Josh Gordon’s Machine Learning Recipes. If the code doesn’t work for you (I am 99 %

sure it will), let me know!

https://www.youtube.com/watch?v=cSKfRcEDGUs&list=PLOU2XLYxmsIIuiBfYad6rFYQU_jL2ryal&index=6

Preview - Slide Available at deeplearningconf.com

Page 67: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Like R? Try this notebook on my Kaggle

https://www.kaggle.com/samdeeplearning/deep-neural-network-for-starters-r/edit

Page 68: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

@edeeplearning

July 27

Deploying Enterprise Deep Learning

Submit your predictions, even! (disclaimer: middle of the pack result)

https://www.kaggle.com/samdeeplearning/deep-neural-network-for-starters-r/edit

Preview - Slide Available at deeplearningconf.com

Page 69: Deploying Enterprise Deep Learning Masterclass Preview -  Enterprise Deep Learning

Sam Putnam

Thank you to Google and others who have published diagrams and photos. Slides are for today only.

@edeeplearning

Questions/Comments: [email protected]

Thank you

July 27

Deploying Enterprise Deep Learning