Assignment 3 2
Assignment 3 2
Assignment 3
Due Date: December 16, 2024
• Objective:
In this assignment, you will implement a Recurrent Neural Network (RNN) and a
Long Short-Term Memory (LSTM) network for Natural Language Processing (NLP)
tasks. Specifically, you will build models to perform text classification based on
sentiment analysis of movie reviews.
• Dataset:
You will use the IMDb movie reviews dataset, which consists of 50,000 labeled movie
reviews, split into 25,000 for training and 25,000 for testing. Each review is labeled as
positive or negative.
Dataset link: IMDb Dataset
Note: If the dataset is not accessible, you can use a similar dataset, such as from the
tensorflow_datasets library.
• Tasks:
• Data Preprocessing: Load the IMDb movie reviews dataset.
• Preprocess the text data:
• Tokenize the text, convert to sequences, and pad the sequences.
• Prepare the data for training and testing.
• RNN Implementation:
• Implement a simple Recurrent Neural Network (RNN) model.
• Compile the model with an appropriate loss function and optimizer.
• Train the RNN model on the training data.
• Evaluate the RNN model on the test data and report the accuracy.
• LSTM Implementation:
• Implement a Long Short-Term Memory (LSTM) network.
• Compile the model with an appropriate loss function and optimizer.
• Train the LSTM model on the training data.
• Evaluate the LSTM model on the test data and report the accuracy.
• Comparison:
• Compare the performance of the RNN and LSTM models.
• Discuss which model performs better and why.
• Optional - Hyperparameter Tuning:
• Experiment with different hyperparameters (e.g., number of layers, units,
dropout rates) to improve the model performance.
• Report the best configuration you found.
•