Skip to content

Commit b8cf40f

Browse files
committed
added jupyter colab tutorial ipynb
1 parent e35e1ef commit b8cf40f

File tree

7 files changed

+3705
-12
lines changed

7 files changed

+3705
-12
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
*.ipynb
2-
31
# Byte-compiled / optimized / DLL files
42
__pycache__/
53
*.py[cod]

assets/badges/colab-open.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/badges/colab.svg

Lines changed: 1 addition & 0 deletions
Loading

css/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ a:visited { color: #205caa; }
6363
background-color: #f7f6f1;
6464
}
6565

66+
.colab-badge {
67+
border: 0 !important;
68+
}
69+
6670
/* Custom CSS rules for content */
6771

6872
.embedded-video {

jupyter-colab-tutorial.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
layout: page
3+
title: Jupyter Notebook / Google Colab Tutorial
4+
permalink: /jupyter-colab-tutorial/
5+
---
6+
7+
To get some extra practice with Python, we'll be running the
8+
[Python Numpy Tutorial](python-numpy-tutorial.md) as a Jupyter
9+
notebook or [Google Colaboratory](https://research.google.com).
10+
11+
A Jupyter notebook lets you write and execute
12+
Python code locally in your web browser. Jupyter notebooks
13+
make it very easy to tinker with code and execute it in bits
14+
and pieces; for this reason they are widely used in scientific
15+
computing.
16+
You can choose to run Google's flavor of Jupyter notebooks entirely
17+
in the cloud using Colab. Colab is basically Jupyter notebook on
18+
steroids: it's free, requires no setup, comes preinstalled with many packages
19+
so everyone has access to the same dependencies, is easy to share with the world,
20+
and has free access to hardware accelerators like GPUs and TPUs (with some caveats).
21+
22+
If you wish to run this tutorial
23+
in Colab (recommended), click the `Open in Colab` link below.
24+
25+
<div>
26+
<a href="link to shared drive in cs231n gmail" target="_blank">
27+
<img class="colab-badge" src="/assets/badges/colab-open.svg" alt="Colab Notebook"/>
28+
</a>
29+
</div>
30+
31+
Otherwise, if you're reading this far, we're assuming you wish to run Jupyter notebooks locally. If your virtual environment was installed correctly (as per the [setup instructions]({{site.baseurl}}/setup-instructions/)), `jupyter notebook` should have been automatically installed. Ensure you have activated your environment before proceeding.
32+
33+
First, [download the notebook]() to a directory of your choosing. Then `cd` to that directory and run the following in your terminal:
34+
35+
```
36+
jupyter notebook
37+
```
38+
39+
Once your notebook server is up and running, point your web browser to http://localhost:8888 to
40+
start using your notebooks. If everything worked correctly, you should
41+
see a screen like this, showing all available notebooks in the current
42+
directory:
43+
44+
<div class='fig figcenter'>
45+
<img src='/assets/ipython-tutorial/file-browser.png'>
46+
</div>
47+
48+
Click `Jupyter Notebook Tutorial` and follow the instructions in the notebook.
49+
50+
<!-- If you click through to a notebook file, you will see a screen like this: -->
51+
52+
<!-- <div class='fig figcenter'>
53+
<img src='/assets/ipython-tutorial/notebook-1.png'>
54+
</div>
55+
56+
A Jupyter notebook is made up of a number of **cells**. Each cell can contain
57+
Python code. You can execute a cell by clicking on it (the highlight color will
58+
switch from blue to green) and pressing `Shift-Enter`.
59+
When you do so, the code in the cell will run, and the output of the cell
60+
will be displayed beneath the cell. For example, after running the first cell,
61+
the notebook shoud look like this:
62+
63+
<div class='fig figcenter'>
64+
<img src='/assets/ipython-tutorial/notebook-2.png'>
65+
</div>
66+
67+
Global variables are shared between cells. Executing the second cell thus gives
68+
the following result:
69+
70+
<div class='fig figcenter'>
71+
<img src='/assets/ipython-tutorial/notebook-3.png'>
72+
</div>
73+
74+
There are a few keyboard shortcuts you should be aware of to make your notebook
75+
experience more pleasant. To escape cell editing, press `esc`. The highlight color
76+
should switch back to blue. To place a cell below the current one, press `b`.
77+
To place a cell above the current one, press `a`. Finally, to delete a cell, press `dd`.
78+
79+
You can restart a notebook and clear all cells by clicking `Kernel -> Restart & Clear Output`.
80+
81+
<div class='fig figcenter'>
82+
<img src='/assets/ipython-tutorial/notebook-restart.png'>
83+
</div>
84+
85+
By convention, Jupyter notebooks are expected to be run from top to bottom.
86+
Failing to execute some cells or executing cells out of order can result in
87+
errors. After restarting the notebook, try running the second cell directly:
88+
89+
<div class='fig figcenter'>
90+
<img src='/assets/ipython-tutorial/notebook-error.png'>
91+
</div>
92+
93+
After you have modified a Jupyter notebook for one of the assignments by
94+
modifying or executing some of its cells, remember to **save your changes!**
95+
96+
<div class='fig figcenter'>
97+
<img src='/assets/ipython-tutorial/save-notebook.png'>
98+
</div>
99+
100+
This has only been a brief introduction to Jupyter notebooks, but it should
101+
be enough to get you up and running on the assignments for this course. -->

0 commit comments

Comments
 (0)