In this assignment you will practice writing backpropagation code, and training Neural Networks and Convolutional Neural Networks. The goals of this assignment are as follows:
The IPython notebook FullyConnectedNets.ipynb
will introduce you to our modular layer design, and then use those layers to implement fully-connected networks of arbitrary depth. To optimize these models you will implement several popular update rules.
In the IPython notebook BatchNormalization.ipynb
you will implement batch normalization, and use it to train deep fully-connected networks.
The IPython notebook Dropout.ipynb
will help you implement Dropout and explore its effects on model generalization.
In the IPython Notebook ConvolutionalNetworks.ipynb
you will implement several new layers that are commonly used in convolutional networks.
GPU Quota: Check out this page to get an instance running.
Get assignment: Open up a terminal on the instance, and run the following:
wget http://cs231n.github.io/assignments/2019/spring1819_assignment2.zip
unzip spring1819_assignment2.zip
cd assignment2/
Installing Anaconda: If you decide to work locally, we recommend using the free Anaconda Python distribution, which provides an easy way for you to handle package dependencies. Please be sure to download the Python 3 version, which currently installs Python 3.7. We are no longer supporting Python 2.
Get assignment: Get the assignment code as a zip file here.
Anaconda Virtual environment: Once you have Anaconda installed on your local machine or remote instance (which brings Anaconda with it), it makes sense to create a virtual environment for the course. If you choose not to use a virtual environment, it is up to you to make sure that all dependencies for the code are installed globally on your machine. To set up a virtual environment, run (in a terminal)
conda create -n cs231n python=3.7 anaconda
to create an environment called cs231n
.
Then, to activate and enter the environment, run
source activate cs231n
To exit, you can simply close the window, or run
source deactivate cs231n
Note that every time you want to work on the assignment, you should run source activate cs231n
.
(Optional) You may refer to this page for more detailed instructions on managing virtual environments with Anaconda.
source activate cs231n
python -m ipykernel install --user --name cs231n
cd assignment2/
pip install -r requirements.txt
cs cs231n/
python setup.py build_ext --inplace
Once you have the starter code (regardless of which method you choose above), you will need to download the CIFAR-10 dataset. Run the following from the assignment2
directory:
cd cs231n/datasets
./get_datasets.sh
Let's open a notebook and start. For example, open FullyConnectedNets.ipynb
for Q1.
Here, make sure we change the IPython kernel to the environment we just configured as shown below. If not, we'll get a dependency error when importing the library.
If you are unfamiliar with IPython, you can also refer to cs231n's IPython tutorial.
The instructions in the code will walk us through the work needed to be done and some questions to answer. At last, we'll get a trained model and a test score. When you finish the three required tasks, pack the assignment2/
folder and submit it on http://learn.tsinghua.edu.cn/.
NOTE 1: This year, the assignment2
code has been tested to be compatible with python version 3.7
. You will need to make sure that during your virtual environment setup that the correct version of python
is used.
NOTE 2: There are # *****START OF YOUR CODE
/# *****END OF YOUR CODE
tags denoting the start and end of code sections you should fill out. Take care to not delete or modify these tags, or your assignment may not be properly graded.
This assignment is largely based on cs231n at Stanford. We thank cs231n for making these great materials publicly available.