Lab Assignment 4 - VineethaG/Python_CS5590 GitHub Wiki

Python Lab Assignment-4

Team ID: 12
Team Member 1: Vineetha Gummadi, Class ID: 10
Team Member 2: Amulya Kasaraneni, Class ID: 14

Objective:

  • To implement the text classification using CNN model & RNN model and comparing the results.
  • To implement the image classification using CNN model.
  • To work with different datasets.

Task 1: Implementing text classification using CNN model:

Dataset:

  • Used polarity dataset with has 1000 positive and 1000 negative processed reviews on movies http://www.cs.cornell.edu/people/pabo/movie-review-data/ for both CNN & RNN for text classification.

Code Snippet:

CNN Model:

Output

Accuracy & Loss values by tuning the hyper parameters:

tensor graph

Task 2: Implementing text classification using RNN model:

Code Snippet:

RNN Model

Two stack LTSM:

Output

Tensor graph

Task 3: Comparing the results of CNN & RNN models:

  • We used polarity dataset with has 1000 positive and 1000 negative processed reviews on movies http://www.cs.cornell.edu/people/pabo/movie-review-data/ for both the models for text classification
  • We have tuned the hyperparameters to each model for text classification.
  • Tuned the hyperparameters for CNN model to get the good accuracy and less loss and achieved this for Adam optimizer with learning rate 0.01. i.e. Accuracy: 0.833333, Loss: 0.165703.
  • Also tuned the parameters for RNN model to get the good accuracy and less loss with Adam optimizer with learning rate 0.1 i.e. Accuracy= ”1”, loss=”0.085024”.
  • We observed that for RNN is accuracy is high compared to CNN model.
  • Which one is better depends on what the problem is. RNN is mostly useful for the problem to remember things, good for sequential data and predicting the future text. CNN is simple for text classification compared to RNN.

Task 4: Image Classification using CNN model:

Dataset: CIFAR 10

It consists of 60000 images and 10 classes i.e. 6000 images per class. There are 50000 train images and 10000 test images. Data set is divided into 5 training batches and 1 test batches each batch with 10000 images.

Code Snippet:

Output

Hyperparameters:

  • Learning rate= 0.1
  • Adam optimizer
  • Epochs = 100
  • Dropout probability = 0.5

Approach:

  • CIFAR 10 dataset has 5 batches. We calculated loss and accuracy by considering single batch.
  • Each batch contains the labels and images of airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck.
  • Implemented the normalize function to take the image data and return the normalized Numpy array.
  • Implemented the one hot encoding for preprocessing.
  • Built the model: implemented the conv2d_maxpool function to apply the convolution, max pooling and then fully connected layer function.

Google Drive Link:

https://drive.google.com/open?id=1lad9vvAfQpWP-9gYXVoXbq0ddG9ke3ld

Youtube Link:

https://www.youtube.com/watch?v=KU_cDNQn1K8
⚠️ **GitHub.com Fallback** ⚠️