Part 1: ASL Classification
We will build and train a convolutional neural network (CNN) for classification of ASL signs.
1.1 ASL Dataset
We will load the dataset and display a sample for each sign of the training dataset from it:
Our training set is made up of 28x28 grayscale images of ASL sign.
ResNet
1. Identity Block
We'll implement an identity block, in which the skip connection "skips over" 3 hidden layers.
Arguments:
- X - input tensor of shape (m, n_H_prev, n_W_prev, n_C_prev)
- f - integer, specifying the shape of the middle CONV's window for the main path
- filters - python list of integers, defining the number of filters in the CONV layers of the main path
- stage - integer, used to name the layers, depending on their position in the network
- block - string/character, used to name the layers, depending on their position in the network
Returns: X - output of the identity block, tensor of shape (n_H, n_W, n_C)
Sanity check if the identity function works
2. Convolutional Block
Arguments:
- X - input tensor of shape (m, n_H_prev, n_W_prev, n_C_prev)
- f - integer, specifying the shape of the middle CONV's window for the main path
- filters - python list of integers, defining the number of filters in the CONV layers of the main path
- stage - integer, used to name the layers, depending on their position in the network
- block - string/character, used to name the layers, depending on their position in the network
- s - Integer, specifying the stride to be used
Returns: X - output of the convolutional block, tensor of shape (n_H, n_W, n_C)
Again testing if convolutional block works
3 Building our first ResNet model (50 layers)
Arguments:
- input_shape - shape of the images of the dataset
- classes - integer, number of classes
Returns: model - a Model() instance in Keras
Visualization of the model
We will visualize a random image
1.2 Neural Network for ASL Classification
We'll first build a simple neural network consisting of two fully connected layers and apply this to the digit classification task. Our network will ultimately output a probability distribution over the 29 classes (0-28).
Evaluate accuracy on the test dataset
Find best Hyperparamters for optimizer and lerning rate
Best: 0.022437 using {'learning_rate': 0.001, 'optimizer': 'Nadam'}
1.3 Convolutional Neural Network (CNN) for ASL Classification
Train and test the CNN model
Now, as before, we can define the loss function, optimizer, and metrics through the compile
method. Compile the CNN model with an optimizer and learning rate of choice:
As was the case with the fully connected model, we can train our CNN using the fit
method via the Keras API.
Visualizing the training performance