Homework 2
1. Instructions
In this assignment, you will construct an image classifier using a Convolutional Neural Network (CNN).
Download the Fashion-MNIST dataset (https://github.com/zalandoresearch/fashion-mnist). Normalize the data such that pixel values are floats in [0, 1] using linear scaling, and use the normalized data for all of the following questions.
1.1. CNN
Train a convolutional neural network on the training data with the following layer specifications:
- 2D convolutional layer, 28 filters, 3x3 window size, ReLU activation
- 2x2 max pooling
- 2D convolutional layer, 56 filters, 3x3 window size, ReLU activation
- fully-connected layer, 56 nodes, ReLU activation
- fully-connected layer, 10 nodes, softmax activation
Use the Adam optimizer, 32 observations per batch, and sparse categorical cross-entropy loss. Use the train and test splits provided by fashion-mnist. Use the last 12000 samples of the training data as a validation set. Train for 10 epochs.
- Print the number of trainable parameters in the model
- Evaluate training and validation accuracy at the end of each epoch, and plot them as line plots on the same set of axes.
- Evaluate accuracy on the test set.
- Show an example from the test set for each class where the model misclassifies.
- Comment on any other observations about the model performance
Resources
- You are encouraged but not required to use Python for this assignment. If you choose to use Python, consider the following deep learning libraries:
- Keras (recommended)
- TensorFlow
- Pytorch
- http://karpathy.github.io/2019/04/25/recipe/
Submission
Submit your results as:
- A plain python file named
submission.py
. This file should generate all results for this assignment, including visualizations. - A Markdown file named
submission.md
. This markdown file should include all generated images, and answer all questions for this assignment. We should be able to grade your assignment by rendering the markdown file. All generated plots should be included in the markdown file. - A directory of images
imgs/
containing.png
or.jpg
images for the plots. - DO NOT add your virtual environment, training data, or model checkpoints to your submission.
Include ALL of the above files in your submission.
To include images in your Markdown file, you can use the following syntax:

Replace Alt text
with a description of the image and path/to/image.png
with the actual path to your image file. If your images are located in a folder named images
, for example, you would write:
