Machine Learning

Machine Learning
Professional Certificate Program in Machine Learning & Artificial Intelligence

Wednesday, April 1, 2020

Machine Learning Walk Through 1


Training a Convolutional Neural Network (CNN) to Classify using Virtual Machine 
(Paper presented during the October, 2019 MFNERC Circle of Knowledge and Practices Conference)


 Introduction

Our world is changing in many ways and one of the things which is going to have a huge impact on our future is artificial intelligence – AI.  Computers are already replacing manual labor.

Can it also replace mental labor?

Siri the digital assistant to Apple device is a pseudo intelligent digital personal assistant. Siri has the ability to listen to how we talk, how we ask for things, what we ask for and more and then tailor her results and actions to better fit our needs even if we speak to her in another language. 

Alexa on the other hand, is an AI device of a different nature. This is a device meant to help us in all aspects of our home life. Much like most phone assistants all we have to do to get Alexa to do something is talk to her, however her range is what makes Alexa so valuable. 

Background of the Study

How does a computers learn to recognize objects?  How do we teach machines to see just like we do and thus be able to name objects, identifying people, inferring 3D geometry of things and ultimately understanding relations, emotions, actions and intentions?

Developing neural networks, one of the ways towards teaching machines to learn, results in  an interconnected networks of digital processors that accept inputs, process measurements of the aforementioned inputs towards generating a calculated output. The system learns to identify what kind of output would result from the initial inputs. After which, the machine develops the ability to respond on its own. 


Much like how our brain works.





The brain works with the help of the brain cells which are called neurons. Each neuron communicates by forming networks 
with other neurons among other cells. These neurons are called dendrites and receives signals from other neurons. Dendrites around the cell body receives all signals, adds them all up and forward these signals to axons. The axons will then fire these signals to the next neurons. Information from one neuron flows to another neuron across a small gap at the end of a neuron called a synapse.

http://www.mplsvpn.info/2017/11/what-is-neuron-and-artificial-neuron-in.html

Modified National Institute of Standards and Technology (MNIST)

The MNIST database (Modified National Institute of Standards) is a large database of handwritten digits that is commonly used for training various image processing systems. The database is also widely used for training and testing in the field of machine learning.



Deep learning 101: A Walkthrough Image Classification with TensorFlow Using Google Colaboratory

1. https://www.youtube.com/watch?v=_1pyxSR7dMk
    Note: You Tube Video on how to run the program in Google Colab

2. https://colab.research.google.com/drive/1zZFslX-eXhZ4iBnMoaNnmoBWpJgAdBbf
    Note: This link explain MNIST identifying handwritten numbers.


Read about the documentation for our libraries of interest at these links:

1

#Import libraries of interest
#Tensorflow (with keras), numpy, matplotlib, pandas and other common libraries
#come pre-installed
import tensorflow as tf
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt

print(tf.__version__)


2
#Load dataset
fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()


(Run/Download data from https…)

Load the Data Sheet
Fashion MNIST is similar to MNIST (has 10 output categories) but will instead use images of clothing and shoes. It has a total of 70,000 images with of size 28 x 28. Each image is mapped to a single label based on the type of clothing/footwear present in it. The labels are 0, 1, 2 ..., 9. 60,000 images are used for training while 10,000 images are used for testing.
They correspond to 'T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag' and 'Ankle boot' respectively.
One can directly load and import the dataset from the list of datasets keras offers. It is split into training images and labels, and test images and labels for convenience.

3
#Class names are included to conveniently view them, in addition to the output labels from 0-9
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']

4
#Sanity check to see shape of train_images
train_images.shape

Run/(60000, 28, 28)

The output suggests that there are 60,000 images, each of shape 28 x 28. Since the images are all grayscale, the number of channels for the image does not show. This would be different if we were using color images. (For example, it would be 28 x 28 x 28 for RGB images)
5
#Verify if we have the correct number of labels corresponding to train images
len(train_labels)

Run/6000

6
#View what the labels are for our train images
#Notice that these are numbers and not the names of clothing
train_labels

Run/array([9, 0, 0, ..., 3, 0, 5], dtype=uint8)


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


<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3258874375499028"
     crossorigin="anonymous"></script>