Permalink
Browse files

Fix broken equations by changing to kramdown

  • Loading branch information...
1 parent 35c3821 commit 484c43d753b5f11b34f244d64df987ff675d744d @myungsub myungsub committed Apr 3, 2016
View
@@ -12,7 +12,7 @@ English to Korean translation project for the notes and assignments for Stanford
To view the rendered site in your browser,
1. Install Jekyll - follow the instructions [[here](https://jekyllrb.com/docs/installation/)]
-2. `git clone https://github.com/yourUserName/cs231n.git`
+2. Assuming that you have already forked this repo, `git clone https://github.com/yourUserName/cs231n.git`
3. `cd cs231n`
4. `jekyll serve`
5. View the website at http://127.0.0.1:4000/cs231n/
View
@@ -30,24 +30,24 @@ for the project. 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 on your machine.
To set up a virtual environment, run the following:
-```bash
+~~~bash
cd assignment1
sudo pip install virtualenv # This may already be installed
virtualenv .env # Create a virtual environment
source .env/bin/activate # Activate the virtual environment
pip install -r requirements.txt # Install dependencies
# Work on the assignment for a while ...
deactivate # Exit the virtual environment
-```
+~~~
**Download data:**
Once you have the starter code, you will need to download the CIFAR-10 dataset.
Run the following from the `assignment1` directory:
-```bash
+~~~bash
cd cs231n/datasets
./get_datasets.sh
-```
+~~~
**Start IPython:**
After you have the CIFAR-10 data, you should start the IPython notebook server from the
View
@@ -26,15 +26,15 @@ for the project. 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 on your machine.
To set up a virtual environment, run the following:
-```bash
+~~~bash
cd assignment2
sudo pip install virtualenv # This may already be installed
virtualenv .env # Create a virtual environment
source .env/bin/activate # Activate the virtual environment
pip install -r requirements.txt # Install dependencies
# Work on the assignment for a while ...
deactivate # Exit the virtual environment
-```
+~~~
You can reuse the virtual environment that you created for the first assignment,
but you will need to run `pip install -r requirements.txt` after activating it
@@ -44,16 +44,16 @@ to install additional dependencies required by this assignment.
Once you have the starter code, you will need to download the CIFAR-10 dataset.
Run the following from the `assignment2` directory:
-```bash
+~~~bash
cd cs231n/datasets
./get_datasets.sh
-```
+~~~
**Compile the Cython extension:** Convolutional Neural Networks require a very efficient implementation. We have implemented of the functionality using [Cython](http://cython.org/); you will need to compile the Cython extension before you can run the code. From the `cs231n` directory, run the following command:
-```bash
+~~~bash
python setup.py build_ext --inplace
-```
+~~~
**Start IPython:**
After you have the CIFAR-10 data, you should start the IPython notebook server from the
View
@@ -28,15 +28,15 @@ for the project. 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 on your machine.
To set up a virtual environment, run the following:
-```bash
+~~~bash
cd assignment3
sudo pip install virtualenv # This may already be installed
virtualenv .env # Create a virtual environment
source .env/bin/activate # Activate the virtual environment
pip install -r requirements.txt # Install dependencies
# Work on the assignment for a while ...
deactivate # Exit the virtual environment
-```
+~~~
You can reuse the virtual environment that you created for the first or second
assignment, but you will need to run `pip install -r requirements.txt` after
@@ -52,18 +52,18 @@ Run the following from the `assignment3` directory:
NOTE: After downloading and unpacking, the data and pretrained models will
take about 900MB of disk space.
-```bash
+~~~bash
cd cs231n/datasets
./get_datasets.sh
./get_tiny_imagenet_splits.sh
./get_pretrained_models.sh
-```
+~~~
**Compile the Cython extension:** Convolutional Neural Networks require a very efficient implementation. We have implemented of the functionality using [Cython](http://cython.org/); you will need to compile the Cython extension before you can run the code. From the `cs231n` directory, run the following command:
-```bash
+~~~bash
python setup.py build_ext --inplace
-```
+~~~
**Start IPython:**
After you have downloaded the data and compiled the Cython extensions,
@@ -17,7 +17,7 @@ In this assignment you will practice putting together a simple image classificat
- get a basic understanding of performance improvements from using **higher-level representations** than raw pixels (e.g. color histograms, Histogram of Gradient (HOG) features)
## Setup
-You can work on the assignment in one of two ways: locally on your own machine, or on a virtual machine through Terminal.com.
+You can work on the assignment in one of two ways: locally on your own machine, or on a virtual machine through Terminal.com.
### Working in the cloud on Terminal
@@ -32,24 +32,24 @@ The preferred approach for installing all the assignment dependencies is to use
**[Option 2] Manual install, virtual environment:**
If you'd like to (instead of Anaconda) go with a more manual and risky installation route you will likely want to create a [virtual environment](http://docs.python-guide.org/en/latest/dev/virtualenvs/) for the project. 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 the following:
-```bash
+~~~bash
cd assignment1
sudo pip install virtualenv # This may already be installed
virtualenv .env # Create a virtual environment
source .env/bin/activate # Activate the virtual environment
pip install -r requirements.txt # Install dependencies
# Work on the assignment for a while ...
deactivate # Exit the virtual environment
-```
+~~~
**Download data:**
Once you have the starter code, you will need to download the CIFAR-10 dataset.
Run the following from the `assignment1` directory:
-```bash
+~~~bash
cd cs231n/datasets
./get_datasets.sh
-```
+~~~
**Start IPython:**
After you have the CIFAR-10 data, you should start the IPython notebook server from the
@@ -79,7 +79,7 @@ The IPython Notebook **svm.ipynb** will walk you through implementing the SVM cl
The IPython Notebook **softmax.ipynb** will walk you through implementing the Softmax classifier.
### Q4: Two-Layer Neural Network (25 points)
-The IPython Notebook **two\_layer\_net.ipynb** will walk you through the implementation of a two-layer neural network classifier.
+The IPython Notebook **two_layer_net.ipynb** will walk you through the implementation of a two-layer neural network classifier.
### Q5: Higher Level Representations: Image Features (10 points)
@@ -54,34 +54,34 @@ for the project. 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 the following:
-```bash
+~~~bash
cd assignment2
sudo pip install virtualenv # This may already be installed
virtualenv .env # Create a virtual environment
source .env/bin/activate # Activate the virtual environment
pip install -r requirements.txt # Install dependencies
# Work on the assignment for a while ...
deactivate # Exit the virtual environment
-```
+~~~
**Download data:**
Once you have the starter code, you will need to download the CIFAR-10 dataset.
Run the following from the `assignment2` directory:
-```bash
+~~~bash
cd cs231n/datasets
./get_datasets.sh
-```
+~~~
**Compile the Cython extension:** Convolutional Neural Networks require a very
efficient implementation. We have implemented of the functionality using
[Cython](http://cython.org/); you will need to compile the Cython extension
before you can run the code. From the `cs231n` directory, run the following
command:
-```bash
+~~~bash
python setup.py build_ext --inplace
-```
+~~~
**Start IPython:**
After you have the CIFAR-10 data, you should start the IPython notebook server
@@ -48,35 +48,35 @@ for the project. 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 the following:
-```bash
+~~~bash
cd assignment3
sudo pip install virtualenv # This may already be installed
virtualenv .env # Create a virtual environment
source .env/bin/activate # Activate the virtual environment
pip install -r requirements.txt # Install dependencies
# Work on the assignment for a while ...
deactivate # Exit the virtual environment
-```
+~~~
**Download data:**
Once you have the starter code, you will need to download the processed MS-COCO dataset, the TinyImageNet dataset, and the pretrained TinyImageNet model. Run the following from the `assignment3` directory:
-```bash
+~~~bash
cd cs231n/datasets
./get_coco_captioning.sh
./get_tiny_imagenet_a.sh
./get_pretrained_model.sh
-```
+~~~
**Compile the Cython extension:** Convolutional Neural Networks require a very
efficient implementation. We have implemented of the functionality using
[Cython](http://cython.org/); you will need to compile the Cython extension
before you can run the code. From the `cs231n` directory, run the following
command:
-```bash
+~~~bash
python setup.py build_ext --inplace
-```
+~~~
**Start IPython:**
After you have the data, you should start the IPython notebook server
View
@@ -104,9 +104,9 @@ to get to your instance if you lose your key.
Once you download your key, you should change the permissions of the key to
user-only RW, In Linux/OSX you can do it by:
-```
+~~~
$ chmod 600 PEM_FILENAME
-```
+~~~
Here `PEM_FILENAME` is the full file name of the .pem file you just downloaded.
After this is done, click on "Launch Instances", and you should see a screen
@@ -127,26 +127,26 @@ are now ready to ssh into the instance.
First, note down the Public IP of the instance from the instance listing. Then,
do:
-```
+~~~
ssh -i PEM_FILENAME ubuntu@PUBLIC_IP
-```
+~~~
Now you should be logged in to the instance. You can check that Caffe is working
by doing:
-```
+~~~
$ cd caffe
$ ./build/tools/caffe time --gpu 0 --model examples/mnist/lenet.prototxt
-```
+~~~
We have Caffe, Theano, Torch7, Keras and Lasagne pre-installed. Caffe python
bindings are also available by default. We have CUDA 7.5 and CuDNN v3 installed.
If you encounter any error such as
-```
+~~~
Check failed: error == cudaSuccess (77 vs. 0) an illegal memory access was encountered
-```
+~~~
you might want to terminate your instance and start over again. I have observed
this rarely, and I am not sure what causes this.
View
@@ -71,10 +71,10 @@ As our first approach, we will develop what we call a **Nearest Neighbor Classif
Suppose now that we are given the CIFAR-10 training set of 50,000 images (5,000 images for every one of the labels), and we wish to label the remaining 10,000. The nearest neighbor classifier will take a test image, compare it to every single one of the training images, and predict the label of the closest training image. In the image above and on the right you can see an example result of such a procedure for 10 example test images. Notice that in only about 3 out of 10 examples an image of the same class is retrieved, while in the other 7 examples this is not the case. For example, in the 8th row the nearest training image to the horse head is a red car, presumably due to the strong black background. As a result, this image of a horse would in this case be mislabeled as a car.
-You may have noticed that we left unspecified the details of exactly how we compare two images, which in this case are just two blocks of 32 x 32 x 3. One of the simplest possibilities is to compare the images pixel by pixel and add up all the differences. In other words, given two images and representing them as vectors \\( I\_1, I\_2 \\) , a reasonable choice for comparing them might be the **L1 distance**:
+You may have noticed that we left unspecified the details of exactly how we compare two images, which in this case are just two blocks of 32 x 32 x 3. One of the simplest possibilities is to compare the images pixel by pixel and add up all the differences. In other words, given two images and representing them as vectors $$ I_1, I_2 $$ , a reasonable choice for comparing them might be the **L1 distance**:
$$
-d\_1 (I\_1, I\_2) = \sum\_{p} \left| I^p\_1 - I^p\_2 \right|
+d_1 (I_1, I_2) = \sum_{p} \left| I^p_1 - I^p_2 \right|
$$
Where the sum is taken over all pixels. Here is the procedure visualized:
@@ -86,27 +86,27 @@ Where the sum is taken over all pixels. Here is the procedure visualized:
Let's also look at how we might implement the classifier in code. First, let's load the CIFAR-10 data into memory as 4 arrays: the training data/labels and the test data/labels. In the code below, `Xtr` (of size 50,000 x 32 x 32 x 3) holds all the images in the training set, and a corresponding 1-dimensional array `Ytr` (of length 50,000) holds the training labels (from 0 to 9):
-```python
+~~~python
Xtr, Ytr, Xte, Yte = load_CIFAR10('data/cifar10/') # a magic function we provide
# flatten out all images to be one-dimensional
Xtr_rows = Xtr.reshape(Xtr.shape[0], 32 * 32 * 3) # Xtr_rows becomes 50000 x 3072
Xte_rows = Xte.reshape(Xte.shape[0], 32 * 32 * 3) # Xte_rows becomes 10000 x 3072
-```
+~~~
Now that we have all images stretched out as rows, here is how we could train and evaluate a classifier:
-```python
+~~~python
nn = NearestNeighbor() # create a Nearest Neighbor classifier class
nn.train(Xtr_rows, Ytr) # train the classifier on the training images and labels
Yte_predict = nn.predict(Xte_rows) # predict labels on the test images
# and now print the classification accuracy, which is the average number
# of examples that are correctly predicted (i.e. label matches)
print 'accuracy: %f' % ( np.mean(Yte_predict == Yte) )
-```
+~~~
Notice that as an evaluation criterion, it is common to use the **accuracy**, which measures the fraction of predictions that were correct. Notice that all classifiers we will build satisfy this one common API: they have a `train(X,y)` function that takes the data and the labels to learn from. Internally, the class should build some kind of model of the labels and how they can be predicted from the data. And then there is a `predict(X)` function, which takes new data and predicts the labels. Of course, we've left out the meat of things - the actual classifier itself. Here is an implementation of a simple Nearest Neighbor classifier with the L1 distance that satisfies this template:
-```python
+~~~python
import numpy as np
class NearestNeighbor(object):
@@ -134,22 +134,22 @@ class NearestNeighbor(object):
Ypred[i] = self.ytr[min_index] # predict the label of the nearest example
return Ypred
-```
+~~~
If you ran this code, you would see that this classifier only achieves **38.6%** on CIFAR-10. That's more impressive than guessing at random (which would give 10% accuracy since there are 10 classes), but nowhere near human performance (which is [estimated at about 94%](http://karpathy.github.io/2011/04/27/manually-classifying-cifar10/)) or near state-of-the-art Convolutional Neural Networks that achieve about 95%, matching human accuracy (see the [leaderboard](http://www.kaggle.com/c/cifar-10/leaderboard) of a recent Kaggle competition on CIFAR-10).
**The choice of distance.**
There are many other ways of computing distances between vectors. Another common choice could be to instead use the **L2 distance**, which has the geometric interpretation of computing the euclidean distance between two vectors. The distance takes the form:
$$
-d\_2 (I\_1, I\_2) = \sqrt{\sum\_{p} \left( I^p\_1 - I^p\_2 \right)^2}
+d_2 (I_1, I_2) = \sqrt{\sum_{p} \left( I^p_1 - I^p_2 \right)^2}
$$
In other words we would be computing the pixelwise difference as before, but this time we square all of them, add them up and finally take the square root. In numpy, using the code from above we would need to only replace a single line of code. The line that computes the distances:
-```python
+~~~python
distances = np.sqrt(np.sum(np.square(self.Xtr - X[i,:]), axis = 1))
-```
+~~~
Note that I included the `np.sqrt` call above, but in a practical nearest neighbor application we could leave out the square root operation because square root is a *monotonic function*. That is, it scales the absolute sizes of the distances but it preserves the ordering, so the nearest neighbors with or without it are identical. If you ran the Nearest Neighbor classifier on CIFAR-10 with this distance, you would obtain **35.4%** accuracy (slightly lower than our L1 distance result).
@@ -180,7 +180,7 @@ Luckily, there is a correct way of tuning the hyperparameters and it does not to
Here is what this might look like in the case of CIFAR-10:
-```python
+~~~python
# assume we have Xtr_rows, Ytr, Xte_rows, Yte as before
# recall Xtr_rows is 50,000 x 3072 matrix
Xval_rows = Xtr_rows[:1000, :] # take first 1000 for validation
@@ -202,7 +202,7 @@ for k in [1, 3, 5, 10, 20, 50, 100]:
# keep track of what works on the validation set
validation_accuracies.append((k, acc))
-```
+~~~
By the end of this procedure, we could plot a graph that shows which values of *k* work best. We would then stick with this value and evaluate once on the actual test set.
Oops, something went wrong.

0 comments on commit 484c43d

Please sign in to comment.