Skip to content

Commit 0946060

Browse files
author
Seth Weidman
committed
First commit for reorganizing beginner tutorials
1 parent e0791cf commit 0946060

File tree

5 files changed

+55
-77
lines changed

5 files changed

+55
-77
lines changed

beginner_source/blitz/cifar10_tutorial.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ def forward(self, x):
185185
print('Finished Training')
186186

187187
########################################################################
188+
# Let's quickly save our trained model:
189+
190+
PATH = './data'
191+
torch.save(net.state_dict(), PATH)
192+
193+
########################################################################
194+
# See `here <https://pytorch.org/docs/stable/notes/serialization.html>`_
195+
# for more details on saving PyTorch models.
196+
#
188197
# 5. Test the network on the test data
189198
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
190199
#
@@ -204,6 +213,13 @@ def forward(self, x):
204213
imshow(torchvision.utils.make_grid(images))
205214
print('GroundTruth: ', ' '.join('%5s' % classes[labels[j]] for j in range(4)))
206215

216+
########################################################################
217+
# Next, let's load back in our saved model (note: saving and re-loading the model
218+
# wasn't necessary here, we only did it to illustrate how to do so):
219+
220+
net = Net()
221+
net.load_state_dict(torch.load(PATH))
222+
207223
########################################################################
208224
# Okay, now let us see what the neural network thinks these examples above are:
209225

beginner_source/data_loading_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""
3-
Data Loading and Processing Tutorial
4-
====================================
3+
Writing Custom Datasets, DataLoaders and Transforms
4+
===================================================
55
**Author**: `Sasank Chilamkurthy <https://chsasank.github.io>`_
66
77
A lot of effort in solving any machine learning problem goes in to

beginner_source/pytorch_with_examples.rst

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -123,43 +123,6 @@ network:
123123

124124
.. includenodoc:: /beginner/examples_autograd/two_layer_net_custom_function.py
125125

126-
TensorFlow: Static Graphs
127-
-------------------------
128-
129-
PyTorch autograd looks a lot like TensorFlow: in both frameworks we
130-
define a computational graph, and use automatic differentiation to
131-
compute gradients. The biggest difference between the two is that
132-
TensorFlow's computational graphs are **static** and PyTorch uses
133-
**dynamic** computational graphs.
134-
135-
In TensorFlow, we define the computational graph once and then execute
136-
the same graph over and over again, possibly feeding different input
137-
data to the graph. In PyTorch, each forward pass defines a new
138-
computational graph.
139-
140-
Static graphs are nice because you can optimize the graph up front; for
141-
example a framework might decide to fuse some graph operations for
142-
efficiency, or to come up with a strategy for distributing the graph
143-
across many GPUs or many machines. If you are reusing the same graph
144-
over and over, then this potentially costly up-front optimization can be
145-
amortized as the same graph is rerun over and over.
146-
147-
One aspect where static and dynamic graphs differ is control flow. For
148-
some models we may wish to perform different computation for each data
149-
point; for example a recurrent network might be unrolled for different
150-
numbers of time steps for each data point; this unrolling can be
151-
implemented as a loop. With a static graph the loop construct needs to
152-
be a part of the graph; for this reason TensorFlow provides operators
153-
such as ``tf.scan`` for embedding loops into the graph. With dynamic
154-
graphs the situation is simpler: since we build graphs on-the-fly for
155-
each example, we can use normal imperative flow control to perform
156-
computation that differs for each input.
157-
158-
To contrast with the PyTorch autograd example above, here we use
159-
TensorFlow to fit a simple two-layer net:
160-
161-
.. includenodoc:: /beginner/examples_autograd/tf_two_layer_net.py
162-
163126
`nn` module
164127
===========
165128

beginner_source/transfer_learning_tutorial.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# -*- coding: utf-8 -*-
22
"""
3-
Transfer Learning Tutorial
4-
==========================
3+
Transfer Learning for Computer Vision Tutorial
4+
==============================================
55
**Author**: `Sasank Chilamkurthy <https://chsasank.github.io>`_
66
7-
In this tutorial, you will learn how to train your network using
8-
transfer learning. You can read more about the transfer learning at `cs231n
9-
notes <https://cs231n.github.io/transfer-learning/>`__
7+
In this tutorial, you will learn how to train a convolutional neural network for
8+
image classification using transfer learning. You can read more about the transfer
9+
learning at `cs231n notes <https://cs231n.github.io/transfer-learning/>`__
1010
1111
Quoting these notes,
1212

index.rst

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,11 @@ Getting Started
3838
:tooltip: Learn how to load and preprocess/augment data from a non trivial dataset
3939
:description: :doc:`/beginner/data_loading_tutorial`
4040

41-
.. customgalleryitem::
42-
:tooltip: This tutorial introduces the fundamental concepts of PyTorch through self-contained examples
43-
:figure: /_static/img/thumbnails/examples.png
44-
:description: :doc:`/beginner/pytorch_with_examples`
45-
46-
.. customgalleryitem::
47-
:figure: /_static/img/thumbnails/sphx_glr_transfer_learning_tutorial_001.png
48-
:tooltip: In transfer learning, a model created from one task is used in another
49-
:description: :doc:`beginner/transfer_learning_tutorial`
50-
51-
.. customgalleryitem::
52-
:figure: /_static/img/thumbnails/floppy.png
53-
:tooltip: Explore use cases for the saving and loading of PyTorch models
54-
:description: :doc:`beginner/saving_loading_models`
55-
56-
.. .. galleryitem:: beginner/saving_loading_models.py
57-
5841
.. customgalleryitem::
5942
:figure: /_static/img/thumbnails/pytorch_tensorboard.png
6043
:tooltip: Learn to use TensorBoard to visualize data and model training
6144
:description: :doc:`intermediate/tensorboard_tutorial`
6245

63-
.. customgalleryitem::
64-
:figure: /_static/img/torch.nn.png
65-
:tooltip: Use torch.nn to create and train a neural network
66-
:description: :doc:`beginner/nn_tutorial`
67-
68-
6946
.. raw:: html
7047

7148
<div style='clear:both'></div>
@@ -80,9 +57,9 @@ Image
8057
:description: :doc:`intermediate/torchvision_tutorial`
8158

8259
.. customgalleryitem::
83-
:figure: /_static/img/thumbnails/eye.png
84-
:tooltip: Finetune and feature extract the torchvision models
85-
:description: :doc:`beginner/finetuning_torchvision_models_tutorial`
60+
:figure: /_static/img/thumbnails/sphx_glr_transfer_learning_tutorial_001.png
61+
:tooltip: In transfer learning, a model created from one task is used in another
62+
:description: :doc:`beginner/transfer_learning_tutorial`
8663

8764
.. customgalleryitem::
8865
:figure: /_static/img/stn/Five.gif
@@ -247,7 +224,7 @@ Extending PyTorch
247224
<div style='clear:both'></div>
248225

249226
PyTorch in Other Languages
250-
-------------
227+
--------------------------
251228

252229
.. customgalleryitem::
253230
:tooltip: Using the PyTorch C++ Frontend
@@ -258,6 +235,24 @@ PyTorch in Other Languages
258235

259236
<div style='clear:both'></div>
260237

238+
PyTorch Fundamentals In-Depth
239+
-----------------------------
240+
241+
.. customgalleryitem::
242+
:tooltip: This tutorial introduces the fundamental concepts of PyTorch through self-contained examples
243+
:figure: /_static/img/thumbnails/examples.png
244+
:description: :doc:`/beginner/pytorch_with_examples`
245+
246+
.. customgalleryitem::
247+
:figure: /_static/img/torch.nn.png
248+
:tooltip: Use torch.nn to create and train a neural network
249+
:description: :doc:`beginner/nn_tutorial`
250+
251+
.. raw:: html
252+
253+
<div style='clear:both'></div>
254+
255+
261256
.. -----------------------------------------
262257
.. Page TOC
263258
.. -----------------------------------------
@@ -269,12 +264,7 @@ PyTorch in Other Languages
269264

270265
beginner/deep_learning_60min_blitz
271266
beginner/data_loading_tutorial
272-
beginner/pytorch_with_examples
273-
beginner/transfer_learning_tutorial
274-
beginner/deploy_seq2seq_hybrid_frontend_tutorial
275267
intermediate/tensorboard_tutorial
276-
beginner/saving_loading_models
277-
beginner/nn_tutorial
278268

279269
.. toctree::
280270
:maxdepth: 2
@@ -283,7 +273,7 @@ PyTorch in Other Languages
283273
:caption: Image
284274

285275
intermediate/torchvision_tutorial
286-
beginner/finetuning_torchvision_models_tutorial
276+
beginner/transfer_learning_tutorial
287277
intermediate/spatial_transformer_tutorial
288278
advanced/neural_style_tutorial
289279
beginner/fgsm_tutorial
@@ -357,3 +347,12 @@ PyTorch in Other Languages
357347
:caption: PyTorch in Other Languages
358348

359349
advanced/cpp_frontend
350+
351+
.. toctree::
352+
:maxdepth: 2
353+
:includehidden:
354+
:hidden:
355+
:caption: PyTorch Fundamentals In-Depth
356+
357+
beginner/pytorch_with_examples
358+
beginner/nn_tutorial

0 commit comments

Comments
 (0)