Homework 5: Two-Digit MNIST with a CNN

Classify pairs of handwritten digits using PyTorch

Implement a CNN on paired MNIST images and report its training loss, test results, and example predictions.
Deep learningPython + PyTorch
Your goal: implement a convolutional neural network (CNN) in Python and PyTorch to classify two side-by-side MNIST digits as a number from 00 through 99. Treat each combined image as a whole when classifying it.
Submithw5submission.pdf
AnnouncedMon, Nov 9, 2026after Lecture 29: Convolutional Neural Networks
DueMon, Nov 23, 202611:59 PM Eastern · 14 days
ToolsPython, PyTorch, torchvision

Submission

Submit one PDF named hw5submission.pdf through Canvas. Late submissions follow the syllabus policy. Scoring is 80% completeness and 20% correctness; this homework contributes 10% of the course grade.

Your PDF should include:

  • The complete code used for the implementation.
  • A plot of training loss across epochs, with the x-axis labeled as epochs and the y-axis as loss.
  • The final test loss and accuracy.
  • At least two correctly classified and two incorrectly classified test images, each captioned with its predicted and true labels.

Dataset and starter code

Each input is a \(28\times56\) image containing two MNIST digits. If the left digit is \(a\) and the right digit is \(b\), its label is \(10a+b\), giving 100 classes (00-99). The starter provides 30,000 training pairs and 5,000 test pairs from the corresponding MNIST splits. Choose your CNN architecture and implement training and evaluation.

Four side-by-side pairs of handwritten digits. Their labels are 18, 78, 32, and 53.

Four paired MNIST samples with class labels 18, 78, 32, and 53.
Starter packageTwo-digit MNIST

Dataset creation, data loaders, and sample-image plotting. Complete the CNN and training code.