Last modified: 2026-03-23 19:13
Status: RELEASED.
Due date: Wednesday Mar 25, 2026 by end of day (11:59 pm ET) in Medford, MA
Jump to: Background Starter Notebook Problem 1 Problem 2 Problem 3
Turn-in links:
- CODE turned in to: https://www.gradescope.com/courses/1220989/assignments/7826063
- Complete your reflection here: https://docs.google.com/forms/d/e/1FAIpQLSckm0qU8ESaWkVVJszYdgcyCSW8_3mD9BubBHD2R8DpTJWzWQ/viewform?usp=publish-editor
Files to Turn In: Your code submission should contain this file, without any folder structure:
hw5.ipynb
Please submit your completed .ipynb notebook file.
This assignment is in a different format from other assignments so far this semester. As opposed to running python code in a local environment, this assignment is designed to be completed entirely in Google colab. You should be able to complete the notebook and run it in colab without exceeding the free tier computational resources. All instructions are embedded in the notebook, and you will submit your completed notebook and not a separate report to Gradescope. When completing each problem, make sure all code, output, and figures appear directly below the problem heading in the notebook so it's clear which figures and output correspond to which question.
Evaluation Rubric:
- 95% python notebook submission
- 5% reflection
Background
In this assignment you will build, train, and evaluate Convolutional Neural Networks (CNNs) using PyTorch — one of the most widely used deep learning frameworks in both research and industry. You will apply CNNs to two real image classification problems including the MNIST Handwritten Digits dataset and a biological imaging dataset where you will classify the activation state of human t-cells.
The starter notebook contains most of the code you will need already; if you get stuck PyTorch has extensive documentation.
Starter Notebook
The starter notebook can be found here: https://colab.research.google.com/drive/1tChPCEoOooI-hfczBP0nqfCVN7Y3NnX6?usp=sharing. Create a copy of the notebook for your own use.
This notebook includes starter code for loading and preprocessing both the MNIST and T-Cell datasets, defining the CNN architecture, and setting up the training and validation loops.
We encourage you to read through all starter code carefully before beginning — the comments explain what each section does and will help you understand how the data flows through the network before you start experimenting.
Also included are helper functions for training, validation, and plotting metrics that you will use throughout both parts of the assignment.
Note: We include a list of the problems and parts below so you can make sure you didn't miss anything in the notebook, but the problem instructions are more complete inside the starter notebook.
Part 1: Building Convolutional Neural Networks using Pytorch for MNIST dataset
MNIST is a classic benchmark dataset in machine learning consisting of 70,000 grayscale images of handwritten digits (0–9), each 28×28 pixels. We will be building a CNN using PyTorch and train it to classify the label for a grayscale image.
This pipeline has already been setup for you. Work your way through the python notebook running each already completed cell, so that you understand how the CNN is built and how the training and validation functions work.
Problem 1: Experiment with the CNN model and the MNIST dataset.
For each part below, output the training + validation loss and accuracy graphs. Also report the test accuracy. Report how each change affected model performance and training time. Please make sure all code, output, and figures appear directly below the problem heading in the notebook for each section.
1A: Optimizer Try out different optimizers with the initial hyperparameters found in the starter notebook. Discuss the effects of the different optimizers, which one you think performs the best on MNIST, and why.
1B: Batch Size and Learning Rate Given the best optimizer you found, experiment with batch size and learning rate.
Part 2: T-Cell Image Data Classification
Immunotherapy is a cancer treatment that harnesses the body's own immune cells to attack tumors. T-cells are an important part of the immune system and a common target for immunotherapy. However, for most immunotherapy treatments that target T-cells to be effective, the T-cells used must be in an active state. Being able to quickly and accurately classify T-cells by activation state is therefore critical to the success of many immunotherapy treatments.
Our goal is to classify the grayscale image of a single T-cell as Active (capable of attacking cancer cells, selected for treatment) or Quiescent (inactive, discarded from the treatment pipeline). This is a binary image classification problem.
More information about this dataset can be found here.
Problem 2: Simple PyTorch CNN Model for binary image classification
Complete the implementation of the SimpleCNN class with the architecture specified in the notebook. Make sure to look into the size of the images in the data set to help determine the dimensions of the different layers.
Problem 3: T-Cell Image Classification with Binary CNN
3A: Training the CNN Use the template from the CNN MNIST example to define the loss function (BCE), optimizer and set up a training and validation loop with the simple binary CNN you just developed in Problem 2. Apply this to the T-Cell Image data set. Please train your model for at least 15 epochs and graph the training + validation loss and accuracies. Use the following hyperparameters:
- batch size = 32
- loss function = BCELoss
- optimizer = Adam optimizer
- learning rate = 0.001
3B: Experimentation with CNN architecture Experiment with the architecture of the CNN model. You may but are not required to also vary any hyperparameters you desire. You do not need to by systematic explore a set of networks, alter the layers and try to get a feel for what works best in this scenario. However, only calculate test accuracy after you choose a final architecture. Report what you found to work best, training and validation loss, and the testing AUCROC of the final model you choose.
3C: Discussion
Discuss what you found. What neural network architecture changes did you try? What seemed to work well and what didn't work well in this application? Why do you think so?