Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JGS594 Lecture 08

JGS594 Lecture 08

Software Engineering for Machine Learning
Image Recognition I
(202202)

B546a9b97d993392e4b22b74b99b91fe?s=128

Javier Gonzalez
PRO

February 03, 2022
Tweet

More Decks by Javier Gonzalez

Other Decks in Programming

Transcript

  1. jgs SER 594 Software Engineering for Machine Learning Lecture 08:

    Image Recognition with DL4J Dr. Javier Gonzalez-Sanchez javiergs@asu.edu javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment
  2. jgs Previously …

  3. 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
  4. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 4

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

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

    jgs DL4J | Training
  7. jgs Image Recognition Neural Networks

  8. 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.
  9. 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
  10. jgs Input

  11. 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.
  12. 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
  13. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 13

    jgs CIFAR-10 dataset | Samples
  14. 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
  15. 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
  16. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 16

    jgs Load Data (28 x 28) x 70,000
  17. 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.
  18. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 18

    jgs Code
  19. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 19

    jgs Iterator
  20. jgs Model Case 1

  21. 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.
  22. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 22

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

    jgs Training
  24. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 24

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

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

    jgs Results
  27. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 27

    jgs Results Is this Good enough?
  28. jgs 🙁 To be continued …

  29. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 29

    jgs Questions
  30. Javier Gonzalez-Sanchez | SER 594 | Spring 2022 | 30

    jgs Reference § Deeplearning4j Suite Overview https://deeplearning4j.konduit.ai § Source Code
  31. jgs SER 594 Software Engineering for Machine Learning Javier Gonzalez-Sanchez,

    Ph.D. javiergs@asu.edu 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.