Deep_Learning_2 - SaranAkkiraju/Python_and_Deep_Learning_Programming_ICP GitHub Wiki

Objective

  • Using the history object in the source code, plot the loss and accuracy for both training data and validation data. (try to analyze if the model had the overfitting or not?)
  • Plot one of the images in the test data, and then do inferencing to check what the prediction of the fitted model on that single image in the test data
  • We had used 2 hidden layers and relu activation. Try to change the number of hidden layers and the activation to tanh or sigmoid and see what happens

Importing the necessary Libraries

C1

Reading Data

C2

O1

  • Splitting the MINST dataset into both training and test data.
  • Outputting the training image

Scaling the data

C3

Converting image of shape 28*28 to 784 dimensional and it is fed in to the network as a single feature.This is done both for the training and test data

Data Pre-Processing

C4

  • Converting the data to float.
  • Scaling the data to make sure that each is in the range between 0 and 1.
  • Converting the train and test labels to categorical variables.

Modelling and adding layers to the model.

C5

  • Initializing the deep learning sequential model.
  • Initial layer is activation: Relu and No of neurons are 512
  • 2nd activation layer - Relu , No of neurons are 512
  • 3rd layer - both Tanh and sigmoid. sigmoid with No of neurons 512 gives better results
  • final layer is softmax layer and No of neurons are 10.
  • Loss function used is categorical_crossentropy, metric used is accuracy, batch size is 256 and no of epochs is 20

O6 Accuracy is 96.74

Loss

C6

O2

Accuracy

C7

O3

Image and verification

C8

O4

Plot one of the image in the test data, and then do inferencing to check what the prediction of the fitted model on that single image in the test data

Bonus

Modelling deep learning model without scaling.

O5 Accuracy is 93