Skip to content

Commit 58ff8b4

Browse files
committed
added colab setup tutorial
1 parent 04ad090 commit 58ff8b4

File tree

5 files changed

+154
-9
lines changed

5 files changed

+154
-9
lines changed

_config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Course materials and notes for Stanford class CS231n: Convolutiona
55
baseurl: ""
66
url: "http://cs231n.github.io"
77
twitter_username: cs231n
8-
github_username: cs231n
8+
github_username: cs231n
99

1010
# Build settings
1111
markdown: kramdown
@@ -16,4 +16,3 @@ kramdown:
1616
input: GFM
1717
auto_ids: true
1818
syntax_highlighter: rouge
19-

assets/badges/colab.svg

Lines changed: 1 addition & 0 deletions
Loading

assignments/2020/assignment1.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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).

python-numpy-tutorial.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ for the rest of you, this section will serve as a quick crash course on both
2222
the Python programming language and its use for scientific
2323
computing. We'll also introduce notebooks, which are a very convenient way
2424
of tinkering with Python code. Some of you may have previous knowledge in Matlab,
25-
in which case we also recommend the [numpy for Matlab users](http://wiki.scipy.org/NumPy_for_Matlab_Users)
25+
in which case we also recommend the [numpy for Matlab users](https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html)
2626
page.
2727

2828

@@ -57,6 +57,7 @@ page.
5757

5858
## Jupyter and Colab Notebooks
5959

60+
Before we dive into Python, we'd like to briefly talk about *notebooks*.
6061
A Jupyter notebook lets you write and execute
6162
Python code *locally* in your web browser. Jupyter notebooks
6263
make it very easy to tinker with code and execute it in bits

setup.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,42 @@
11
---
22
layout: page
3-
title: Setup Instructions
3+
title: Software Setup
44
permalink: /setup-instructions/
55
---
6-
- [Working remotely on Google Cloud](#working-remotely-on-google-cloud)
6+
7+
This year, the recommended way to work on assignments is through [Google Colaboratory](https://colab.research.google.com/). However, if you already own GPU-backed hardware and would prefer to work locally, we provide you with instructions for setting up a virtual environment.
8+
9+
- [Working remotely on Google Colaboratory](#working-remotely-on-google-colaboratory)
710
- [Working locally on your machine](#working-locally-on-your-machine)
811
- [Anaconda virtual environment](#anaconda-virtual-environment)
912
- [Python venv](#python-venv)
1013
- [Installing packages](#installing-packages)
1114

12-
You can work on the assignment in one of two ways: **locally** on your own machine, or **remotely** on a Google Cloud virtual machine (VM).
15+
### Working remotely on Google Colaboratory
16+
17+
Google Colaboratory is basically a combination of Jupyter notebook and Google Drive. It runs entirely in the cloud and comes
18+
preinstalled with many packages (e.g. PyTorch and Tensorflow) so everyone has access to the same
19+
dependencies. Even cooler is the fact that Colab benefits from free access to hardware accelerators
20+
like GPUs and TPUs which will be particularly useful for assignments 2 and 3.
21+
22+
**Requirements**. To use Colab, you must have a Google account with an associated Google Drive. Assuming you have both, you can connect Colab to your Drive with the following steps:
23+
24+
1. Click the wheel in the top right corner and select `Settings`.
25+
2. Click on the `Manage Apps` tab.
26+
3. At the top, select `Connect more apps` which should bring up a `GSuite Marketplace` window.
27+
4. Search for Colab then click `Add`.
28+
29+
Every assignment provides you with a download link to a zip file containing all Colab notebooks for that particular assignment. You can visit [Colab](https://colab.research.google.com/) and use the `Upload` pane to upload and work on a specific notebook at a time.
30+
31+
**Best Practices**. There are a few things you should be aware of when working with Colab. The first thing you should do when a Colab notebook loads is to save a copy to your drive. You can do this by selecting `File -> Save a copy in Drive`. The second thing to note is that resource limits aren't guaranteed in Colab (the price for being free). If you are idle for too long or your connection time exceeds 12 hours, the Colab VM is disconnected. Make sure you save your progress frequently to prevent loss of work. To read more about resource limitations, click [here](https://research.google.com/colaboratory/faq.html).
32+
33+
**Using a GPU**. Using a GPU is as simple as switching the runtime in Colab. Specifically, click `Runtime -> Change runtime type -> Hardware Accelerator -> GPU` and your Colab instance will automatically be backed by GPU compute.
1334

14-
### Working remotely on Google Cloud
15-
As part of this course, you can use Google Cloud for your assignments. We recommend this route for anyone who is having trouble with installation set-up, or if you would like to use better CPU/GPU resources than you may have locally. Please see the set-up tutorial [here](https://github.com/cs231n/gcloud/) for more details.
35+
If you're interested in learning more about Colab, we encourage you to visit the resources below:
1636

17-
**Note:** after following these instructions, you may skip the remaining sections.
37+
* [Intro to Google Colab](https://www.youtube.com/watch?v=inN8seMm7UI)
38+
* [Welcome to Colab](https://colab.research.google.com/notebooks/intro.ipynb)
39+
* [Overview of Colab Features](https://colab.research.google.com/notebooks/basic_features_overview.ipynb)
1840

1941
### Working locally on your machine
2042
If you wish to work locally, you should use a virtual environment. You can install one via Anaconda (recommended) or via Python's native `venv` module. Ensure you are using Python 3.7 as **we are no longer supporting Python 2**.

0 commit comments

Comments
 (0)