ICP_11 - Girees737/KDM_Projects GitHub Wiki

Description:

This ICP is all about the implementation of the basic CNN model using different hyperparameters.

Objective:

The main objective of this assignment is to implement a CNN model with a different data set and find the accuracy of it.

Design Implementation:

Initially, I have imported all the required libraries to build the model.

Dataset description:

It's a CIFAR-10 (Canadian Institute For Advanced Research) Dataset for this assignment. The dataset consists of 60,000 32 x 32 color images in 10 classes, with 6,000 images per class. There are 50,000 training images and 10,000 test images. These images are taken in varying lighting conditions and at different angles, and since these are colored images, and we will see that there are many variations in the color itself of similar objects.

Key features of the images:

  1. Images are colored in CIFAR-10
  2. Each image is 32 x 32 pixel

Code Implementation:

  1. Loaded the data, performed Normalization on that and reduced the pixel values from [0,255] to [-0.5, 0.5]. This will make it easier to train the model.

  2. Updated the shape values to (32, 32, 3) according to the size of the images (colored) and displayed the shape of each training & Testing image, labels.

  3. Converted the train and test labels to one hot encoders using "to_categorical" as the activation function we have is softmax in the output layer.

Note: We use softmax as the activation function in the output layer only if we have more than 2 class in our target feature.

  1. Built a model using below parameters. a. num_filters- The number of filters is the number of neurons since each neuron performs a different convolution on the input to the layer (more precisely, the neurons' input weights form convolution kernels). Dropout - Dropouts are the regularization technique that is used to prevent overfitting in the model. Dropouts are added to randomly switching some percentage of neurons of the network. When the neurons are switched off the incoming and outgoing connection to those neurons is also switched off. This is done to enhance the learning of the model. b. filter_size - It refers to the dimensions of the filter/kernel in the ConvNet (3x3 is the currently most widely used filter size. This is because 3x3 is usually the smallest filter size to do image processing). c. pool_size - The size of the smaller matrix that will be overlaid upon the feature map. In this example, we will use a value of 2, which indicates that our pooling matrix will be a 2x2 matrix.

  1. Configured the model that we build above with the below hyper parameters for training process.

a. The optimizer: the Adam gradient-based optimizer - It is key metric to updated weights for neuron in the neural networks. The loss function: categorical_crossentropy: As we got more than 2 classes we are using 'categorical_crossentropy'. A list of metrics. Since this is a classification problem, we’ll just have Keras report on the accuracy metric.

  1. started training the CNN model by calling fit() function.

With above model, we achieved an accuracy of 0.5958 on the validation dataset as seen above.
  1. Taken the first ten images from test dataset and displayed the actual labels.

Video Link: https://youtu.be/rvrZ95KVtzE

Conclusion:

In ICP, I have understood how a sequential model like CNN can be build using keras and tensorflow libraries and how an unstructured data like images can be preprocessed for image classification. 

Also understood the parameters like loss function for evaluating the model accuracy on validation dataset during training and optimizer like Adam for updating model weights in the back propagation.