Slide 1

Slide 1 text

A Gentle Introduction to Deep Learning for Developers Bradley Holt Program Manager, Developer Advocacy Center for Open-Source Data and AI Technologies @BradleyHolt DOC ID / Month XX, 2018 / © 2018 IBM Corporation

Slide 2

Slide 2 text

Is AI overhyped?

Slide 3

Slide 3 text

Yes

Slide 4

Slide 4 text

Thank you for coming to my talk

Slide 5

Slide 5 text

General AI Metal Skull With Terminator Eye by L.C. Nøttaasen, on Flickr (CC BY-SA 2.0).

Slide 6

Slide 6 text

Broad AI -[ electrIc b88Gal88 ]- by JD Hancock, on Flickr (CC BY 2.0).

Slide 7

Slide 7 text

Narrow AI Danbo on the Lookout by IQRemix, on Flickr (CC BY-SA 2.0).

Slide 8

Slide 8 text

Deep Learning http://codait.org/

Slide 9

Slide 9 text

Demo: Object Identification and Image Segmentation with magicat https://github.com/CODAIT/magicat

Slide 10

Slide 10 text

https://github.com/CODAIT/magicat

Slide 11

Slide 11 text

Install magicat $ npm install -g magicat + [email protected] added 255 packages from 209 contributors in 11.798s

Slide 12

Slide 12 text

23895621638_535be71dee_k.jpg 37038669284_899d7784a9_k.jpg 37489697170_31d05aa027_k.jpg 37699459356_24fd526a5e_k.jpg 37699976806_5ce694be36_k.jpg Animal photos by Susanne Nilsson, on Flickr (CC BY-SA 2.0).

Slide 13

Slide 13 text

Scan Directory with magicat $ magicat . Scanning directory '/Users/bradleydholt/tfjs-demos/magicat'... The image '23895621638_535be71dee_k.jpg' contains the following segments: background, cat. The image '37038669284_899d7784a9_k.jpg' contains the following segments: background, sheep. The image '37489697170_31d05aa027_k.jpg' contains the following segments: background, sheep. The image '37699459356_24fd526a5e_k.jpg' contains the following segments: background, cat. The image '37699976806_5ce694be36_k.jpg' contains the following segments: background, horse.

Slide 14

Slide 14 text

background, cat background, sheep background, sheep background, cat background, horse Animal photos by Susanne Nilsson, on Flickr (CC BY-SA 2.0).

Slide 15

Slide 15 text

Save Image Segment with magicat $ magicat 37699976806_5ce694be36_k.jpg --save horse The image '37699976806_5ce694be36_k.jpg' contains the following segments: background, horse. saved 37699976806_5ce694be36_k-horse.png Animal photos by Susanne Nilsson, on Flickr (CC BY-SA 2.0).

Slide 16

Slide 16 text

Demo: Object Identification and Image Segmentation with the Magic Cropping Tool https://developer.ibm.com/patterns/max-image-segmenter-magic-cropping-tool-web-app/

Slide 17

Slide 17 text

https://developer.ibm.com/patterns/max-image-segmenter-magic-cropping-tool-web-app/

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Deep Learning Use Cases https://ibm.biz/max-developers

Slide 21

Slide 21 text

Software Programming Untitled by Marcin Wichary, on Flickr (CC BY 2.0).

Slide 22

Slide 22 text

0101100100101100000110101101 0101001001100000110101101011 0110010010101010011101001011 0101010011100101010101010000 1010101011100000011010101010 1001000110000011010011010101 0010001011010101011101000101 Software Program Business Logic

Slide 23

Slide 23 text

0101100100101100000110101101 0101001001100000110101101011 0110010010101010011101001011 0101010011100101010101010000 1010101011100000011010101010 1001000110000011010011010101 0010001011010101011101000101 Software Program Input Program Execution Output

Slide 24

Slide 24 text

Deep Learning

Slide 25

Slide 25 text

Input Layer Hidden Layers Output Layer

Slide 26

Slide 26 text

Labeled Training Data Backpropagation Animal photos by Susanne Nilsson, on Flickr (CC BY-SA 2.0). Output Errors Cat ❌ Not Cat ❌ Cat ❌ Cat Cat

Slide 27

Slide 27 text

Input Neural Network Inferencing Output Cat Animal photos by Susanne Nilsson, on Flickr (CC BY-SA 2.0).

Slide 28

Slide 28 text

Neural Network Inferencing Output Not Cat Input Animal photos by Susanne Nilsson, on Flickr (CC BY-SA 2.0).

Slide 29

Slide 29 text

Machine Learning Libraries The Leeds Library by Michael D Beckwith, on Flickr (CC0 1.0).

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Demo: Basic Classification https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 33

Slide 33 text

Goal & Context • Train a neural network to classify images of clothing • Classifications include dress, sneaker, etc. • We will use the Keras high-level API within TensorFlow https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 34

Slide 34 text

Fashion-MNIST • Training set of 60,000 article of clothing images • Test set of 10,000 examples can be used to evaluate image classification accuracy • Each example is a 28x28 grayscale image • Each example has an associated label from 10 classes (T-shirt/top, trouser, pullover, etc.) https://github.com/zalandoresearch/fashion-mnist

Slide 35

Slide 35 text

Fashion-MNIST Images https://github.com/zalandoresearch/fashion-mnist

Slide 36

Slide 36 text

Fashion-MNIST Image Labels Label Class 0 T-shirt/top 1 Trouser 2 Pullover 3 Dress 4 Coat 5 Sandal 6 Shirt 7 Sneaker 8 Bag 9 Ankle boot https://github.com/zalandoresearch/fashion-mnist

Slide 37

Slide 37 text

https://jupyter.org/

Slide 38

Slide 38 text

Import Libraries In [3]: # TensorFlow and tf.keras import tensorflow as tf from tensorflow import keras # Helper libraries import numpy as np import matplotlib.pyplot as plt print(tf.__version__) https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 39

Slide 39 text

Import Fashion-MNIST Dataset In [4]: fashion_mnist = keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() In [5]: class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat’, 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'] https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 40

Slide 40 text

Explore the Data In [6]: train_images.shape Out[6]: (60000, 28, 28) In [7]: len(train_labels) Out[7]: 60000 In [8]: train_labels Out[8]: array([9, 0, 0, ..., 3, 0, 5], dtype=uint8) In [9]: test_images.shape Out[9]: (10000, 28, 28) In [10]: len(test_labels) Out[10]: 10000 https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 41

Slide 41 text

Preprocess the Data In [11]: plt.figure() plt.imshow(train_images[0]) plt.colorbar() plt.grid(False) plt.show() https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 42

Slide 42 text

Preprocess the Data In [12]: train_images = train_images / 255.0 test_images = test_images / 255.0 https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 43

Slide 43 text

Preprocess the Data In [13]: plt.figure(figsize=(10,10)) for i in range(25): plt.subplot(5,5,i+1) plt.xticks([]) plt.yticks([]) plt.grid(False) plt.imshow(train_images[i], cmap=plt.cm.binary) plt.xlabel(class_names[train_labels[i]]) plt.show() https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 44

Slide 44 text

https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 45

Slide 45 text

Set Up the Model Layers In [14]: model = keras.Sequential([ keras.layers.Flatten(input_shape=(28, 28)), keras.layers.Dense(128, activation=tf.nn.relu), keras.layers.Dense(10, activation=tf.nn.softmax) ]) https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 46

Slide 46 text

Compile the Model In [15]: model.compile(optimizer='adam’, loss='sparse_categorical_crossentropy’, metrics=['accuracy']) https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 47

Slide 47 text

Train the Model In [16]: model.fit(train_images, train_labels, epochs=5) https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 48

Slide 48 text

Train the Model Epoch 1/5 60000/60000 [==============================] - 4s 61us/step - loss: 0.4985 - acc: 0.8261 Epoch 2/5 60000/60000 [==============================] - 3s 54us/step - loss: 0.3747 - acc: 0.8646 Epoch 3/5 60000/60000 [==============================] - 4s 58us/step - loss: 0.3359 - acc: 0.8771 Epoch 4/5 60000/60000 [==============================] - 3s 55us/step - loss: 0.3123 - acc: 0.8846 Epoch 5/5 60000/60000 [==============================] - 4s 59us/step - loss: 0.2945 - acc: 0.8912 https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 49

Slide 49 text

Evaluate Accuracy In [17]: test_loss, test_acc = model.evaluate(test_images, test_labels) print('Test accuracy:', test_acc) https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 50

Slide 50 text

Evaluate Accuracy 10000/10000 [==============================] - 0s 26us/stepTest accuracy: 0.8748 https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 51

Slide 51 text

Make Predictions In [18]: predictions = model.predict(test_images) https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 52

Slide 52 text

Make Predictions In [19]: predictions[0] Out[19]: array([9.6376725e-06, 4.5565642e-07, 5.0994299e-06, 4.8001135e-07, 4.9554501e-06, 2.0314518e-02, 5.0287876e-05, 1.6105843e-01, 2.2055059e-04, 8.1833553e-01], dtype=float32) https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 53

Slide 53 text

Make Predictions In [20]: np.argmax(predictions[0]) Out[20]: 9 In [21]: test_labels[0] Out[21]: 9 https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 54

Slide 54 text

https://www.tensorflow.org/tutorials/keras/basic_classification

Slide 55

Slide 55 text

Applying Deep Learning Data Science Expertise Computing Resources High-Quality Training Data Model Deployment Time Model Integration Inferencing Code And more…

Slide 56

Slide 56 text

Model Asset Exchange (MAX) Classify Generate Recognize https://developer.ibm.com/exchanges/models/

Slide 57

Slide 57 text

Choose deployable model Deep Learning asset on MAX Deploy Swagger specification Inference endpoint Metadata endpoint Microservice Input pre-processing, model execution, and output post-processing Deploy model Use model https://developer.ibm.com/exchanges/models/

Slide 58

Slide 58 text

AI Lifecycle Deploy Operate Build & Train

Slide 59

Slide 59 text

Building and Training AI Models Model Asset Exchange (MAX)

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

Deploying AI Models ONNX.js Model Asset Exchange (MAX)

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Operating AI Systems Fabric for Deep Learning (FfDL) Train and deploy deep learning models on Kubernetes using TensorFlow, Caffe2, PyTorch, and other frameworks AI Fairness 360 (AIF360) Comprehensive set of fairness metrics for machine learning models, explanations for these metrics, and algorithms to mitigate bias in models Adversarial Robustness Toolbox (ART) Python library for adversarial attacks and defenses for neural networks with multiple framework support

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

What will you build using deep learning? Dynamic Earth - Continental Shelf by NASA Goddard Space Flight Center, on Flickr (CC BY 2.0).

Slide 66

Slide 66 text

Resources: Machine Learning Libraries • TensorFlow https://www.tensorflow.org/ • Train your first neural network: basic classification | TensorFlow https://www.tensorflow.org/tutorials/keras/basic_classification • Keras https://keras.io/ • PyTorch https://pytorch.org/ • Caffe2 https://caffe2.ai/

Slide 67

Slide 67 text

Resources: IBM Developer • IBM Cloud https://ibm.biz/Bd2A5f • Center for Open-Source Data & AI Technologies (CODAIT) http://codait.org/ • IBM Developer Model Asset Exchange (MAX) https://developer.ibm.com/exchanges/models/ • Model Asset Exchange (MAX) Code Patterns https://ibm.biz/max-developers • Deploy a deep learning-powered ‘Magic cropping tool’ https://developer.ibm.com/patterns/max-image-segmenter-magic-cropping-tool-web-app/ • !" magicat https://github.com/CODAIT/magicat

Slide 68

Slide 68 text

Resources: Building and Training AI Models • Project Jupyter https://jupyter.org/ • IBM Developer Model Asset Exchange (MAX) https://developer.ibm.com/exchanges/models/ • IBM Watson Studio https://www.ibm.com/cloud/watson-studio

Slide 69

Slide 69 text

Resources: Deploying AI Models • Data Mining Group (PMML & PFA) http://dmg.org/ • ONNX https://onnx.ai/ • ONNX.js https://github.com/Microsoft/onnxjs • TensorFlow.js https://js.tensorflow.org/ • TensorFlow Lite https://www.tensorflow.org/lite • Core ML https://developer.apple.com/machine-learning/ • IBM Watson Machine Learning https://www.ibm.com/cloud/machine-learning

Slide 70

Slide 70 text

Resources: Operating AI Systems • Fabric for Deep Learning (FfDL) https://github.com/IBM/FfDL • AI Fairness 360 (AIF360) https://github.com/IBM/AIF360 • Adversarial Robustness Toolbox (ART) https://github.com/IBM/adversarial-robustness-toolbox • IBM Watson OpenScale https://www.ibm.com/cloud/watson-openscale

Slide 71

Slide 71 text

Thank you codait.org twitter.com/codait_datalab medium.com/ibm-watson-data-lab github.com/codait developer.ibm.com

Slide 72

Slide 72 text

No content