Skip to main content
Warning: this assignment is not yet released. Check back on March 18, 2026.
This assignment is due on Wednesday, March 25, 2026 before 11:59PM.

Get Started:

  1. Accept the assignment on GitHub Classroom — You’ll get your own private repository with starter code and data
  2. Clone your repo and complete the exercises in hw5_dl.py
  3. Commit regularly as you work (this is part of your grade!)
  4. Push your completed work to GitHub before the deadline

GPU Access: This assignment involves training neural networks. While the models are small enough to train on CPU, GPU access will make training significantly faster. See the Resources section for GPU options.


Learning Objectives

By completing this assignment, you will:


Background

Deep learning has revolutionized medical image analysis. CNNs can now detect diabetic retinopathy, classify skin lesions, and identify lung nodules with expert-level performance. But building these models requires understanding both the deep learning fundamentals and the unique challenges of medical imaging.

In this assignment, you’ll classify chest X-rays using the MedMNIST dataset — a standardized collection designed for educational purposes. You’ll start with a simple CNN, then apply transfer learning, and finally interpret what your model has learned.


The Dataset

We’ll use PneumoniaMNIST from the MedMNIST collection:

The images are intentionally small (28×28) to enable fast training without GPUs while still teaching core concepts.

Class Label Count (Train)
Normal 0 ~1,214
Pneumonia 1 ~3,494

Note: The dataset is imbalanced (~75% pneumonia). Keep this in mind for evaluation!


Instructions

Part 1: Data Loading & Exploration (15 points)

1.1 Load the Dataset (5 pts)

1.2 Visualize the Data (5 pts)

1.3 Data Augmentation (5 pts)


Part 2: Build a Simple CNN (25 points)

2.1 Define the Architecture (10 pts)

Build a CNN from scratch with:

Document your architecture choices.

2.2 Training Loop (10 pts)

Implement a training loop that:

2.3 Training Curves (5 pts)


Part 3: Transfer Learning (25 points)

3.1 Load Pretrained Model (8 pts)

Use a pretrained model (e.g., ResNet18) and adapt it for our task:

3.2 Fine-Tuning Strategy (8 pts)

Implement fine-tuning:

3.3 Compare Models (9 pts)

Create a comparison table:

Model Test Accuracy Test AUC Precision Recall F1
Simple CNN          
ResNet18 (from scratch)          
ResNet18 (pretrained)          

Which model performs best? Why?


Part 4: Model Evaluation (20 points)

4.1 Confusion Matrix & Metrics (8 pts)

For your best model:

4.2 ROC and PR Curves (6 pts)

4.3 Error Analysis (6 pts)


Part 5: Model Interpretability (15 points)

5.1 Visualize Filters (5 pts)

5.2 Grad-CAM Visualization (10 pts)

Implement Grad-CAM to visualize what the model focuses on:


Reflection Questions

Answer these in code comments:

  1. Clinical Deployment: If this model were deployed for pneumonia screening, what threshold would you choose? What are the consequences of false positives vs false negatives?

  2. Limitations: What are three limitations of using MedMNIST (28×28 images) compared to real clinical chest X-rays?

  3. Next Steps: What would you do differently if you had access to full-resolution chest X-rays and a GPU cluster?


Submission via GitHub

  1. Complete your work in hw5_dl.py
  2. Save your figures to the outputs/ directory
  3. Commit your changes with meaningful messages
  4. Push to GitHub before the deadline

Deliverables

Your repository should contain:


Grading Rubric

Component Points
Part 1: Data Loading & Exploration 15
1.1 Load dataset 5
1.2 Visualize data 5
1.3 Data augmentation 5
Part 2: Simple CNN 25
2.1 Define architecture 10
2.2 Training loop 10
2.3 Training curves 5
Part 3: Transfer Learning 25
3.1 Load pretrained model 8
3.2 Fine-tuning strategy 8
3.3 Compare models 9
Part 4: Model Evaluation 20
4.1 Confusion matrix & metrics 8
4.2 ROC and PR curves 6
4.3 Error analysis 6
Part 5: Interpretability 15
5.1 Visualize filters 5
5.2 Grad-CAM 10
Subtotal 100
Git Workflow  
Multiple meaningful commits -5 if missing
Clear commit messages -5 if missing

Resources

GPU Access Options

Documentation


Tips