The objectives of this assignment are to:
- Implement Convolutional Neural Networks (CNNs) and Recurrent Neural Networks (RNNs) using TensorFlow Keras.
- Understand how these architectures handle sequential and spatial data.
- Train, test, and evaluate deep learning models on image and text datasets.
- Experiment with dropout, regularization, and early stopping to improve generalization.
This assignment extends the previous work on feedforward networks by introducing architectures suited for sequence modeling and image classification.
| File | Description |
|---|---|
notebooks/nn.ipynb |
Main notebook containing implementations of convolutional and recurrent neural networks. |
notebooks/nn.py |
Exported Python version of the notebook used for pytest testing. |
notebooks/convolution_and_recurrent_networks.ipynb |
Notebook for running tests and recording pytest results. |
results/nn.html |
Exported HTML version of the notebook for grading and readability. |
tests/test_nn.py |
Provided test file used to validate correctness using pytest. |
README.md |
This file, describing objectives, setup, and submission workflow. |
requirements.txt |
Python dependencies for reproducibility. |
.gitignore |
Specifies intentionally untracked files to keep the repository clean. |
You will complete the following four TensorFlow Keras model creation functions:
| Function | Description | Marks |
|---|---|---|
create_toy_rnn(input_shape, n_outputs) |
Creates a simple Recurrent Neural Network that learns to predict (x_{t-3} - y_t) from sequential input pairs. | 3 |
create_mnist_cnn(input_shape, n_outputs) |
Builds a Convolutional Neural Network (CNN) for digit classification using the MNIST dataset. | 4 |
create_youtube_comment_rnn(vocabulary, n_outputs) |
Constructs an RNN for YouTube Spam Comment classification, processing tokenized text sequences. | 4 |
create_youtube_comment_cnn(vocabulary, n_outputs) |
Builds a CNN for the same YouTube spam detection task using 1D convolutions. | 4 |
| Total Marks | 15 marks |
This project reuses the shared environment created for previous assignments.
# Activate your existing environment
source ~/venvs/ml-env/bin/activate
# Navigate to the assignment directory
cd ~/projects/info527-neural-networks-assignment4
# Install dependencies
pip install -r requirements.txtrequirements.txt
tensorflow>=2.13
keras>=2.13
numpy>=1.24
pytest>=7.0
jupyter>=1.0
ipykernel>=6.0
-
Run all cells in
nn.ipynbto complete your implementations. -
Export your work as:
nn.ipynbnn.htmlnn.py
-
Place the exported
nn.pyfile in the same directory astest_nn.py. -
In Google Colab, upload the required dataset files into a
data/folder:mnist.hdf5Youtube01-Psy,Youtube02-KatyPerry,Youtube03-LMFAO,Youtube04-Eminem,Youtube05-Shakirayoutube-comments.hdf5
-
Run the provided testing notebook
convolution_and_recurrent_networks.ipynband execute:
pytest tests/test_nn.pyExpected Output:
============================= test session starts ==============================
collected 4 items
test_nn.py .... [100%]
============================== 4 passed in XX.XXs ===============================
Submit the following files for grading:
nn.ipynbnn.htmlnn.pyconvolution_and_recurrent_networks.ipynb(with pytest results)
Repository name: info527-neural-networks-assignment4
Description: Implementation of convolutional and recurrent neural networks using TensorFlow Keras. Includes CNNs for image and text classification, RNNs for sequence modeling, and experiments with dropout and early stopping. Part of the Master’s in MIS/ML program at the University of Arizona.
This repository was completed as part of INFO 527: Neural Networks, under the M.S. in Information Science and Machine Learning program (2023–2025).