How it works...

In steps 1 through 3, we extract the true and predicted test class labels and create a confusion matrix. The following image shows the confusion matrix of the current test predictions:

The test accuracy post 700 training iterations is only ~51% and can be further improved by increasing the number of iterations, increasing the batch size, configuring layer parameters such as the number of convolution layers (used 2), types of activation functions (used ReLU), number of fully connected layers (used two), optimization objective function (used accuracy), pooling (used max 2 x 2), dropout probability, and many others.

Step 4 is used to build a facet plot of the test confusion matrix, as shown in the following screenshot:

In step 5, we define a helper function to plot the image along with a header containing both true and predicted classes. The input parameters of the check.image function are (test) flattened input dataset (images.rgb), image number (index), true label (true_lab), and predicted label (pred_lab). Here, the red, green, and blue pixels are initially parsed out, converted into a matrix, appended as a list, and displayed as an image using the plot function.

In step 6, we plot misclassified test images using the helper function of step 5. The input parameters of the plot.misclass.images function are (test) flattened input dataset (images.rgb), a vector of true labels (y_actual), a vector of predicted labels (y_predicted), and a vector of unique ordered character labels (labels). Here, the indices of the misclassified images are obtained and an index is randomly selected to generate the plot. The following screenshot shows a set of six misclassified images with true and predicted labels:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset