Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5303996

Browse files
authored
Merge pull request #453 from brianjo/master
Changed the name of former torchies nn_tutorial
2 parents adc8187 + 4682f19 commit 5303996

5 files changed

Lines changed: 76 additions & 4 deletions

File tree

beginner_source/colab.rst

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Using Tutorial Data from Google Drive in Colab
2+
==============================================
3+
4+
We've added a new feature to tutorials that allows users to open the
5+
notebook associated with a tutorial in Google Colab. You may need to
6+
copy data to your Google drive account to get the more complex tutorials
7+
to work.
8+
9+
In this example, we'll demonstrate how to change the notebook in Colab
10+
to work with the Chatbot Tutorial. To do this, you'll first need to be
11+
logged into Google Drive. (For a full description of how to access data
12+
in Colab, you can view their example notebook
13+
`here <https://colab.research.google.com/notebooks/io.ipynb#scrollTo=XDg9OBaYqRMd>`__.)
14+
15+
To get started open the `Chatbot
16+
Tutorial <https://pytorch.org/tutorials/beginner/chatbot_tutorial.html>`__
17+
in your browser.
18+
19+
At the top of the page click **Run in Google Colab**.
20+
21+
The file will open in Colab.
22+
23+
If you choose, **Runtime** then **Run All**, you'll get an error as the
24+
file can't be found.
25+
26+
To fix this, we'll copy the required file into our Google Drive account.
27+
28+
1. Log into Google Drive.
29+
2. In Google Drive, make a folder named **data**, with a subfolder named
30+
**cornell**.
31+
3. Visit the Cornell Movie Dialogs Corpus and download the ZIP file.
32+
4. Unzip the file on your local machine.
33+
5. Copy the file **movie\_lines.txt** to **data/cornell** folder you
34+
created in Google Drive.
35+
36+
Now we'll need to edit the file in\_ \_Colab to point to the file on
37+
Google Drive.
38+
39+
In Colab, add the following to top of the code section over the line
40+
that begins *corpus\_name*:
41+
42+
::
43+
44+
from google.colab import drive
45+
drive.mount('/content/gdrive')
46+
47+
Change the two lines that follow:
48+
49+
1. Change the **corpus\_name** value to **"cornell"**.
50+
2. Change the line that begins with **corpus** to this:
51+
52+
::
53+
54+
corpus = os.path.join("/content/gdrive/My Drive/data", corpus_name)
55+
56+
We're now pointing to the file we uploaded to Drive.
57+
58+
Now when you click on the **Run cell** button for the code section,
59+
you'll be prompted to authorize Google Drive and you'll get an
60+
authorization code. Paste the code into the prompt in Colab and you
61+
should be set.
62+
63+
Rerun the notebook from **Runtime** / **Run All** menu command and
64+
you'll see it process. (Note that this tutorial takes a long time to
65+
run.)
66+
67+
Hopefully this example will give you a good starting point for running
68+
some of the more complex tutorials in Colab. As we evolve our use of
69+
Colab on the PyTorch tutorials site, we'll look at ways to make this
70+
easier for users.

beginner_source/former_torchies/README.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
Autograd
1010
https://pytorch.org/tutorials/beginner/former_torchies/autograd_tutorial_old.html
1111

12-
3. nn_tutorial.py
12+
3. nnft_tutorial.py
1313
nn package
14-
https://pytorch.org/tutorials/beginner/former_torchies/nn_tutorial.html
14+
https://pytorch.org/tutorials/beginner/former_torchies/nnft_tutorial.html
1515

1616
4. parallelism_tutorial.py
1717
Multi-GPU examples
File renamed without changes.

beginner_source/former_torchies_tutorial.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ In this tutorial, you will learn the following:
1919

2020
/beginner/former_torchies/tensor_tutorial_old
2121
/beginner/former_torchies/autograd_tutorial_old
22-
/beginner/former_torchies/nn_tutorial
22+
/beginner/former_torchies/nnft_tutorial
2323
/beginner/former_torchies/parallelism_tutorial
2424

2525
.. galleryitem:: /beginner/former_torchies/tensor_tutorial_old.py
2626
:figure: /_static/img/tensor_illustration_flat.png
2727

2828
.. galleryitem:: /beginner/former_torchies/autograd_tutorial_old.py
2929

30-
.. galleryitem:: /beginner/former_torchies/nn_tutorial.py
30+
.. galleryitem:: /beginner/former_torchies/nnft_tutorial.py
3131
:figure: /_static/img/torch-nn-vs-pytorch-nn.png
3232

3333
.. galleryitem:: /beginner/former_torchies/parallelism_tutorial.py

index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ starting point, and provides a broad view into how to use PyTorch from the basic
77

88
Some considerations:
99

10+
* We’ve added a new feature to tutorials that allows users to open the notebook associated with a tutorial in Google Colab.
11+
Visit `this page </beginner/colab.html>`_ for more information.
1012
* If you would like to do the tutorials interactively via IPython / Jupyter,
1113
each tutorial has a download link for a Jupyter Notebook and Python source code.
1214
* Additional high-quality examples are available, including image classification,

0 commit comments

Comments
 (0)