Slide 1

Slide 1 text

jgs SER 594 Software Engineering for Machine Learning Lecture 08: Image Recognition with DL4J Dr. Javier Gonzalez-Sanchez [email protected] javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment

Slide 2

Slide 2 text

jgs Previously …

Slide 3

Slide 3 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 3 jgs Guidelines 1. Get data 2. Create a Model 3. Train the Model (i.e., calculate the W, Bias, and so on) 4. Test the Model (accuracy, recall, precision, F1-score, confusion matrix) 5. Deploy the model

Slide 4

Slide 4 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 4 jgs ND4J Input

Slide 5

Slide 5 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 5 jgs DL4J | Our Model

Slide 6

Slide 6 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 6 jgs DL4J | Training

Slide 7

Slide 7 text

jgs Image Recognition Neural Networks

Slide 8

Slide 8 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 8 jgs Definition Using neural networks for image classification is a very straightforward process. 1. We need a dataset with multiple images that we can use to train our neural network. We will use as inputs every single pixel in every image. 2. We expect to get as output a category that we are looking forward to recognizing.

Slide 9

Slide 9 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 9 jgs Problem Recognize handwriting numbers 0 to 9. Steps: 1. Load the dataset 2. Create, train, and evaluate a model 3. Save the model 4. Put our model in an application

Slide 10

Slide 10 text

jgs Input

Slide 11

Slide 11 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 11 jgs Publicly Available Datasets § MNIST dataset. 70, 000 samples of handwritten digits written by high school students and employees of the United States Census Bureau § Iris dataset. which contains three classes of 50 instances each, where each class refers to a type of iris plant; § TinyImageNet (a subset of ImageNet) dataset. An image dataset organized according to the WordNet hierarchy (~1000 per noun); § CIFAR-10 dataset. A a dataset consists of 60,000 32x32 color images in 10 classes, with 6,000 images per class; § Labeled Faces in the Wild, a database of face photographs; and, § Curve Fragment Ground-Truth Dataset, which is used for evaluating edge detection or boundary detection methods.

Slide 12

Slide 12 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 12 jgs Publicly Available Datasets § UC Irvine Machine Learning Repository https://archive-beta.ics.uci.edu ~596 Datasets

Slide 13

Slide 13 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 13 jgs CIFAR-10 dataset | Samples

Slide 14

Slide 14 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 14 jgs MNIST dataset § Each number is stored as an anti-aliased image in black and white and is normalized to fit into a 28x28 pixel bounding box

Slide 15

Slide 15 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 15 jgs Note According to the MNIST website, 1. a one-layer neural network (trained with this dataset) could achieve an error rate of 12% (pretty bad) –– 0.12 2. a deep convolutional neural network could achieve an error rate below 0.25% –– 0.0025 Remember: Go for a value < 0.05

Slide 16

Slide 16 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 16 jgs Load Data (28 x 28) x 70,000

Slide 17

Slide 17 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 17 jgs Load Data § DeepLearning4j comes with out-of-the-box dataset iterators for standard datasets, including one for the MNIST dataset. § The class MnistDataSetIterator allows us to load these standard datasets. § The constructor for MnistDataSetIterator receives three parameters: 1. The batch size, i.e., the number of training samples to work through before comparing to the expected output and calculate the error. 2. The total number of samples in the dataset. 3. A flag to indicate whether the dataset should be binarized (images considered in black & white without shades of gray) or not.

Slide 18

Slide 18 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 18 jgs Code

Slide 19

Slide 19 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 19 jgs Iterator

Slide 20

Slide 20 text

jgs Model Case 1

Slide 21

Slide 21 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 21 jgs First Attempt § Single hidden layer neural network. § Each pixel in the images became an input 28 x 28 = 784 inputs. § Each of the digits that we want to predict became an output; therefore, we have ten neurons in the output layer. § What about the hidden layer? Use the sum of input and output neurons, not a rule, but a starting point. 794 neurons in the hidden layer.

Slide 22

Slide 22 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 22 jgs Model 1

Slide 23

Slide 23 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 23 jgs Training

Slide 24

Slide 24 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 24 jgs Evaluation (Number of classes)

Slide 25

Slide 25 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 25 jgs Evaluation (Number of classes)

Slide 26

Slide 26 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 26 jgs Results

Slide 27

Slide 27 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 27 jgs Results Is this Good enough?

Slide 28

Slide 28 text

jgs 🙁 To be continued …

Slide 29

Slide 29 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 29 jgs Questions

Slide 30

Slide 30 text

Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 30 jgs Reference § Deeplearning4j Suite Overview https://deeplearning4j.konduit.ai § Source Code

Slide 31

Slide 31 text

jgs SER 594 Software Engineering for Machine Learning Javier Gonzalez-Sanchez, Ph.D. [email protected] Spring 2022 Copyright. These slides can only be used as study material for the class CSE205 at Arizona State University. They cannot be distributed or used for another purpose.