---
layout: page
mathjax: true
permalink: /assignments2017/assignment2/
---
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:
- understand **Neural Networks** and how they are arranged in layered
architectures
- understand and be able to implement (vectorized) **backpropagation**
- implement various **update rules** used to optimize Neural Networks
- implement **batch normalization** for training deep networks
- implement **dropout** to regularize networks
- effectively **cross-validate** and find the best hyperparameters for Neural
Network architecture
- understand the architecture of **Convolutional Neural Networks** and train
gain experience with training these models on data
## Setup
You can work on the assignment in one of two ways: locally on your own machine, or on a virtual machine on Google Cloud.
### Working remotely on Google Cloud (Recommended)
**Note:** after following these instructions, make sure you go to **Working on the assignment** below (you can skip the **Working locally** section).
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 Google Cloud GPU set-up tutorial [here](http://cs231n.github.io/gce-tutorial-gpus/) for instructions.
We strongly, strongly recommend using Google Cloud with GPU support for the last part of this assignment (the TensorFlow or PyTorch notebooks), since your training will go much, much faster. :)
### Working locally
Here's how you install the necessary dependencies:
**(OPTIONAL) Installing GPU drivers:**
If you choose to work locally, you are at no disadvantage for the first 3 parts of the assignment. For the last part, which is in TensorFlow or PyTorch, however, having a GPU will be a significant advantage. We recommend using a Google Cloud Instance with a GPU, at least for this part. If you have your own NVIDIA GPU, however, and wish to use that, that's fine -- you'll need to install the drivers for your GPU, install CUDA, install cuDNN, and then install either [TensorFlow](https://www.tensorflow.org/install/) or [PyTorch](http://pytorch.org/). You could theoretically do the entire assignment with no GPUs, though this will make training much slower in the last part.
**Installing Python 3.5+:**
To use python3, make sure to install version 3.5 or 3.6 on your local machine. If you are on Mac OS X, you can do this using [Homebrew](https://brew.sh) with `brew install python3`. You can find instructions for Ubuntu [here](https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-ubuntu-16-04).
**Virtual environment:**
If you decide to work locally, we recommend using [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
cd assignment2
sudo pip install virtualenv # This may already be installed
virtualenv -p python3 .env # Create a virtual environment (python3)
source .env/bin/activate # Activate the virtual environment
pip install -r requirements.txt # Install dependencies
# Note that this does NOT install TensorFlow or PyTorch,
# which you need to do yourself.
# Work on the assignment for a while ...
# ... and when you're done:
deactivate # Exit the virtual environment
```
Note that every time you want to work on the assignment, you should run `source .env/bin/activate` (from within your `assignment2` folder) to re-activate the virtual environment, and `deactivate` again whenever you are done.
## Working on the assignment:
Get the code as a zip file [here](http://cs231n.stanford.edu/assignments/2017/spring1617_assignment2.zip).
### Download data:
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:
```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
`assignment2` directory, with the `jupyter notebook` command. (See the [Google Cloud Tutorial](http://cs231n.github.io/gce-tutorial/) for any additional steps you may need to do for setting this up, if you are working remotely)
If you are unfamiliar with IPython, you can also refer to our
[IPython tutorial](/ipython-tutorial).
### Some Notes
**NOTE 1:** This year, the `assignment2` code has been tested to be compatible with python versions `3.5` and `3.6` (it may work with other versions of `3.x`, but we won't be officially supporting them). For this assignment, we are NOT officially supporting python2. Use it at your own risk. You will need to make sure that during your `virtualenv` setup that the correct version of `python` is used. You can confirm your python version by (1) activating your virtualenv and (2) running `which python`.
**NOTE 2:** If you are working in a virtual environment on OSX, you may *potentially* encounter
errors with matplotlib due to the [issues described here](http://matplotlib.org/faq/virtualenv_faq.html). In our testing, it seems that this issue is no longer present with the most recent version of matplotlib, but if you do end up running into this issue you may have to use the `start_ipython_osx.sh` script from the `assignment1` directory (instead of `jupyter notebook` above) to launch your IPython notebook server. Note that you may have to modify some variables within the script to match your version of python/installation directory. The script assumes that your virtual environment is named `.env`.
### Submitting your work:
Whether you work on the assignment locally or using Google Cloud, once you are done
working run the `collectSubmission.sh` script; this will produce a file called
`assignment2.zip`. Please submit this file on [Canvas](https://canvas.stanford.edu/courses/66461/).
### Q1: Fully-connected Neural Network (25 points)
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.
### Q2: Batch Normalization (25 points)
In the IPython notebook `BatchNormalization.ipynb` you will implement batch
normalization, and use it to train deep fully-connected networks.
### Q3: Dropout (10 points)
The IPython notebook `Dropout.ipynb` will help you implement Dropout and explore
its effects on model generalization.
### Q4: Convolutional Networks (30 points)
In the IPython Notebook ConvolutionalNetworks.ipynb you will implement several new layers that are commonly used in convolutional networks.
### Q5: PyTorch / Tensorflow on CIFAR-10 (10 points)
For this last part, you will be working in either TensorFlow or PyTorch, two popular and powerful deep learning frameworks. **You only need to complete ONE of these two notebooks.** You do NOT need to do both, but a very small amount of extra credit will be awarded to those who do.
Open up either `PyTorch.ipynb` or `TensorFlow.ipynb`. There, you will learn how the framework works, culminating in training a convolutional network of your own design on CIFAR-10 to get the best performance you can.
### Q5: Do something extra! (up to +10 points)
In the process of training your network, you should feel free to implement
anything that you want to get better performance. You can modify the solver,
implement additional layers, use different types of regularization, use an
ensemb
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目资源】: 包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。 包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。 【项目质量】: 所有源码都经过严格测试,可以直接运行。 功能在确认正常工作后才上传。 【适用人群】: 适用于希望学习不同技术领域的小白或进阶学习者。 可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【附加价值】: 项目具有较高的学习借鉴价值,也可直接拿来修改复刻。 对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。 【沟通交流】: 有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
收起资源包目录
斯坦福大学课程cs231n课程作业.zip (137个子文件)
im2col_cython.c 1.1MB
im2col_cython.cp36-win_amd64.exp 709B
frameworkpython 487B
frameworkpython 487B
frameworkpython 487B
readme.html 88B
readme.html 88B
ConvolutionalNetworks.ipynb 354KB
BatchNormalization.ipynb 222KB
LSTM_Captioning.ipynb 52KB
Dropout.ipynb 50KB
GANs-TensorFlow.ipynb 44KB
FullyConnectedNets.ipynb 38KB
GANs-PyTorch.ipynb 38KB
StyleTransfer-PyTorch.ipynb 31KB
TensorFlow.ipynb 30KB
RNN_Captioning.ipynb 29KB
StyleTransfer-TensorFlow.ipynb 29KB
PyTorch.ipynb 29KB
NetworkVisualization-PyTorch.ipynb 26KB
NetworkVisualization-TensorFlow.ipynb 25KB
svm.ipynb 21KB
two_layer_net.ipynb 18KB
knn.ipynb 17KB
features.ipynb 13KB
softmax.ipynb 12KB
muse.jpg 687KB
starry_night.jpg 599KB
tubingen.jpg 397KB
the_scream.jpg 212KB
composition_vii.jpg 198KB
sky.jpg 145KB
puppy.jpg 37KB
kitten.jpg 21KB
kitten.jpg 21KB
im2col_cython.cp36-win_amd64.lib 2KB
README.md 8KB
README.md 196B
README.md 130B
batches.meta 158B
batches.meta 158B
style-transfer-checks-tf.npz 65KB
style-transfer-checks.npz 65KB
gan-checks-tf.npz 2KB
im2col_cython.obj 1.21MB
example_styletransfer.png 1.4MB
gan_outputs_pytorch.png 63KB
gan_outputs_tf.png 54KB
layers.py 32KB
rnn_layers.py 21KB
fc_net.py 21KB
rnn.py 14KB
solver.py 12KB
neural_net.py 11KB
fast_layers.py 10KB
fast_layers.py 10KB
layers.py 9KB
data_utils.py 9KB
data_utils.py 9KB
captioning_solver.py 9KB
k_nearest_neighbor.py 8KB
data_utils.py 8KB
optim.py 7KB
cnn.py 6KB
linear_classifier.py 6KB
linear_svm.py 5KB
features.py 5KB
squeezenet.py 5KB
layer_utils.py 4KB
layer_utils.py 4KB
gradient_check.py 4KB
gradient_check.py 4KB
gradient_check.py 4KB
softmax.py 3KB
coco_utils.py 3KB
optim.py 3KB
image_utils.py 3KB
vis_utils.py 2KB
im2col.py 2KB
im2col.py 2KB
vis_utils.py 2KB
setup.py 298B
setup.py 298B
__init__.py 103B
layers.cpython-36.pyc 17KB
rnn_layers.cpython-36.pyc 14KB
solver.cpython-36.pyc 10KB
layers.cpython-36.pyc 9KB
fast_layers.cpython-36.pyc 8KB
fc_net.cpython-36.pyc 8KB
data_utils.cpython-36.pyc 8KB
captioning_solver.cpython-36.pyc 8KB
data_utils.cpython-36.pyc 7KB
rnn.cpython-36.pyc 6KB
neural_net.cpython-36.pyc 6KB
k_nearest_neighbor.cpython-36.pyc 5KB
layer_utils.cpython-36.pyc 4KB
linear_classifier.cpython-36.pyc 4KB
gradient_check.cpython-36.pyc 4KB
gradient_check.cpython-36.pyc 4KB
共 137 条
- 1
- 2
资源评论
妄北y
- 粉丝: 1w+
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功