|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: Assignment 1 |
| 4 | +mathjax: true |
| 5 | +permalink: /assignments2020/assignment1/ |
| 6 | +--- |
| 7 | + |
| 8 | +This assignment is due on **Wednesday, April 22 2020**. |
| 9 | + |
| 10 | +<details> |
| 11 | +<summary>Handy Download Links</summary> |
| 12 | + |
| 13 | +<p><a href="">Starter code</a> - <a href="">Colab notebooks</a> - <a href="">Jupyter notebooks</a></p> |
| 14 | +</details> |
| 15 | + |
| 16 | +- [Goals](#goals) |
| 17 | +- [Setup](#setup) |
| 18 | + - [Option A: Google Colaboratory (Recommended)](#option-a-google-colaboratory-recommended) |
| 19 | + - [Option B: Local Development](#option-b-local-development) |
| 20 | +- [Q1: k-Nearest Neighbor classifier (20 points)](#q1-k-nearest-neighbor-classifier-20-points) |
| 21 | +- [Q2: Training a Support Vector Machine (25 points)](#q2-training-a-support-vector-machine-25-points) |
| 22 | +- [Q3: Implement a Softmax classifier (20 points)](#q3-implement-a-softmax-classifier-20-points) |
| 23 | +- [Q4: Two-Layer Neural Network (25 points)](#q4-two-layer-neural-network-25-points) |
| 24 | +- [Q5: Higher Level Representations: Image Features (10 points)](#q5-higher-level-representations-image-features-10-points) |
| 25 | +- [Submitting your work](#submitting-your-work) |
| 26 | + |
| 27 | +### Goals |
| 28 | + |
| 29 | +In this assignment you will practice putting together a simple image classification pipeline based on the k-Nearest Neighbor or the SVM/Softmax classifier. The goals of this assignment are as follows: |
| 30 | + |
| 31 | +- Understand the basic **Image Classification pipeline** and the data-driven approach (train/predict stages) |
| 32 | +- Understand the train/val/test **splits** and the use of validation data for **hyperparameter tuning**. |
| 33 | +- Develop proficiency in writing efficient **vectorized** code with numpy |
| 34 | +- Implement and apply a k-Nearest Neighbor (**kNN**) classifier |
| 35 | +- Implement and apply a Multiclass Support Vector Machine (**SVM**) classifier |
| 36 | +- Implement and apply a **Softmax** classifier |
| 37 | +- Implement and apply a **Two layer neural network** classifier |
| 38 | +- Understand the differences and tradeoffs between these classifiers |
| 39 | +- Get a basic understanding of performance improvements from using **higher-level representations** as opposed to raw pixels, e.g. color histograms, Histogram of Gradient (HOG) features, etc. |
| 40 | + |
| 41 | +### Setup |
| 42 | + |
| 43 | +You can work on the assignment in one of two ways: **remotely** on Google Colaboratory or **locally** on your own machine. |
| 44 | + |
| 45 | +**Regardless of the method chosen, ensure you have followed the [setup instructions](/setup-instructions) before proceeding.** |
| 46 | + |
| 47 | +For both methods, you will need to download the starter zip code [here](). |
| 48 | + |
| 49 | +#### Option A: Google Colaboratory (Recommended) |
| 50 | + |
| 51 | +If you choose to work with Google Colab, follow the instructions below: |
| 52 | + |
| 53 | +0. Unzip the starter code zip file. You should see an `assignment1` folder. |
| 54 | +1. Create a folder in your personal Google Drive and upload the `assignment1/cs231n` folder to the Drive folder. We recommend that you call the Google Drive folder `cs231n/assignments/assignment1/` so that the final uploaded folder has the path `cs231n/assignments/assignment1/cs231n`. |
| 55 | +2. The colab notebooks in `assignment1` are the files that end with `_colab.ipynb`. Each Colab notebook corresponds to an assignment question. For each notebook, visit [Google Colab](https://colab.research.google.com/) and upload it using the `Upload -> Browse` menu. |
| 56 | +3. Once you upload the notebook, you will be connected you to a Colab VM. You can mount your Google Drive and access your uploaded |
| 57 | +files by executing the first cell in the notebook. It will prompt you for an authorization code which you can obtain |
| 58 | +from a popup window. The code cell will also automatically download the CIFAR-10 dataset for you. |
| 59 | +4. Once you have completed the assignment question (i.e. reached the end of the notebook), you can save your edited files back to your Drive and move on to the next question. For your convenience, we also provide you with a code cell (the very last one) that automatically saves the modified files for that question back to your Drive. |
| 60 | +6. Repeat steps 2-4 for each remaining notebook. |
| 61 | + |
| 62 | +Once you are done, go to the [submission instructions](#submitting-your-work). |
| 63 | + |
| 64 | +#### Option B: Local Development |
| 65 | + |
| 66 | +If you choose to work locally with Jupyter notebooks, you'll be working with the `.ipynb` files that **do not** end with `_colab`. |
| 67 | + |
| 68 | +**Install Packages**. Once you have the starter code, activate your environment (the one you installed in the [Software Setup]({{site.baseurl}}/setup-instructions/) page) and run `pip install -r requirements.txt`. |
| 69 | + |
| 70 | +**Download CIFAR-10**. Next, you will need to download the CIFAR-10 dataset. Run the following from the `assignment1` directory: |
| 71 | + |
| 72 | +```bash |
| 73 | +cd cs231n/datasets |
| 74 | +./get_datasets.sh |
| 75 | +``` |
| 76 | +**Start Jupyter Server**. After you have the CIFAR-10 data, you should start the Jupyter server from the |
| 77 | +`assignment1` directory by executing `jupyter notebook` in your terminal. |
| 78 | + |
| 79 | +Complete each notebook, then once you are done, go to the [submission instructions](#submitting-your-work). |
| 80 | + |
| 81 | +### Q1: k-Nearest Neighbor classifier (20 points) |
| 82 | + |
| 83 | +The notebook **knn.ipynb** will walk you through implementing the kNN classifier. |
| 84 | + |
| 85 | +### Q2: Training a Support Vector Machine (25 points) |
| 86 | + |
| 87 | +The notebook **svm.ipynb** will walk you through implementing the SVM classifier. |
| 88 | + |
| 89 | +### Q3: Implement a Softmax classifier (20 points) |
| 90 | + |
| 91 | +The notebook **softmax.ipynb** will walk you through implementing the Softmax classifier. |
| 92 | + |
| 93 | +### Q4: Two-Layer Neural Network (25 points) |
| 94 | + |
| 95 | +The notebook **two\_layer\_net.ipynb** will walk you through the implementation of a two-layer neural network classifier. |
| 96 | + |
| 97 | +### Q5: Higher Level Representations: Image Features (10 points) |
| 98 | + |
| 99 | +The notebook **features.ipynb** will examine the improvements gained by using higher-level representations |
| 100 | +as opposed to using raw pixel values. |
| 101 | + |
| 102 | +### Submitting your work |
| 103 | + |
| 104 | +**Important:** Please make sure that the submitted notebooks have been run and the cell outputs are visible. |
| 105 | + |
| 106 | +Once you have completed all notebooks and filled out the necessary code, there are **_two_** steps you must follow to submit your assignment: |
| 107 | + |
| 108 | +**1.** Run the provided submission script in `assignment1` by executing `bash collectSubmission.sh`. |
| 109 | + |
| 110 | +This script will: |
| 111 | + |
| 112 | +* Generate a zip file of your code (`.py` and `.ipynb`) called `a1.zip`. |
| 113 | +* Convert all notebooks into a single PDF file if `PyPDF2` is installed. If `PyPDF2` cannot be found, |
| 114 | + it will generate a separate PDF file for every notebook and it will be your responsibility to concatenate |
| 115 | + them all together with your favorite viewer/editor. Thus, make sure you `pip install PyPDF2` |
| 116 | + to minimize your submission workload. |
| 117 | + |
| 118 | +If your submission for this step was successful, you should see the following display message: |
| 119 | + |
| 120 | +`### Done! Please submit a1.zip and the pdfs to Gradescope. ###` |
| 121 | + |
| 122 | +**2.** Submit the PDF and the zip file to [Gradescope](https://www.gradescope.com/courses/103764). |
0 commit comments