Share
Embed
Deep Learning with TensorFlow
An intro to deep learning with TensorFlow, at GDG Seattle Machine Learning Study Jam.
Margaret Maynard-Reid
August 11, 2018
Transcript
23 slides
-
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow About me code
| speak | write | learn | teach | organize 2 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow AI vs. ML
vs. Deep Learning Artificial Intelligence Machine Learning Deep Learning 4 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow Types of Machine
Learning • Supervised - learning by example, input data has labels • Unsupervised - input data has no labels • Reinforcement learning - learn by feedback from environment An example of supervised learning, classification: Use model to predict Train a model Collect training data 5 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow Training vs Inferences
Training - the process of determining the ideal parameters (for example weights or learning rate) comprising a model. You feed input data into a model and go through an iterative process to come up with the model Inference - apply trained model to make predictions on new examples 6 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow Examples of deep
learning Computer Vision • Image classification - is this a cat? • Object detection - self driving car • Generating new images Generating new images using generative adversarial networks (GANs) Is this a cat? 7 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow A neural network
playground playground.tensorflow.org 8 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow Jupyter Notebook •
Interactive programming in the web browser • Great for visualization • Great for collaboration • Popular tool for studying machine learning / deep learning 9 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow Colab colab.research.google.com/ •
Jupyter Notebook running on Google’s VM in the cloud • Free GPU • TensorFlow is already installed • Save and share from your Drive • Save directly to GitHub Check out my blogpost on Colab, and TensorFlow team’s blog on Colab 10 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow TensorFlow APIs TensorFlow
is a deep learning framework for both research & production Write TensorFlow code in C++, Python, Java, R, Go, SWIFT, JavaScript Deploy to CPU, GPU, TPU, Mobile, Android Things, Raspberry Pi tf.* tf.layers tf.keras Custom Estimator Premade Estimator ← Low level ← mid level ← high level ← model in a box ← distributed execution, tf serving 12 -
TensorFlow operation TensorFlow defines the models as computational graphs •
Nodes - represents mathematical operations • Edges - represent arrays of data To write TensorFlow code: 1. First we define the graph 2. Then run the graph by creating / running the session 13 1 1 2 Add Operator 1 + 1 = 2 -
Why is it called “TensorFlow”? A tensor is an N-dimensional
array of data Rank is the number of dimensions in a tensor • (Rank 0) scalar - single value, 1 • (Rank 1) vector - one dimensional, [1, 2, 3] • (Rank 2) matrix - two dimensional [[1,2,3] [12,3]] • (Rank 3) tensor - multidimensional array • (Rank 4) tensor 14 [[1,2,3] [1, 2, 3] [1,2,3]] -
TensorFlow basics In TensorFlow, data isn’t stored as integers, floats
or strings Instead, data are stored in an object called tensor • tf.constant - the value of the tensor never changes • tf.placeholder - returns a tensor that gets values from data passed to tf.session.run(), for example, training dataset • tf.variable - a tensor with an initial value that can be modified, example: weights and biases. 15 -
Eager Execution Why Eager Execution? • More pythonic • No
long need to create a session then call sessions.run() • Easier for debugging • Enable eager Execution - tf.enable_eager_execution() • Great for research, for production use graph execution Learn more about eager execution: • Programmer’s Guide • Get Started with Eager - Colab tutorial classifies Iris flowers 16 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow TensorFlow learning resources
Tensorflow.org Deep learning with Python by Francois Chollet TensorFlow on Youtube TensorFlow on Twitter #AskTensorFlow #TensorFlowMeets Collection of interactive ML examples (blogpost | website) TensorFlow Dev Summit Blog.tensorflow.org 17 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow Fashion-mnist with tf.keras
MNIST data, hello world of deep learning and computer vision 1. Import data 2. Define a model 3. Train the model 4. Use the model to predict Here is the tutorial link. 19 -
A typical CNN network architecture 20 input conv pool conv
pool conv pool Dense -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow Image augmentation Shift,
flip, zoom or rotate the images - help prevent overfitting: https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html 21 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow Various options of
using TensorFlow From training your own model to calling cloud API: • Train your model from scratch • Transfer learning: ◦ Feature extraction or fine tuning on pre-trained model ◦ TensorFlow hub (https://www.tensorflow.org/hub/) • Use a pre-trained model • Use Google Cloud APIs (cloud.google.com/products/ai/) 22 -
@margaretmz | #MachineLearning | #DeepLearning | #TensorFlow Thank you! @margaretmz
+MargaretMaynardReid @margaretmz 23