Skip to content

Commit 63f987d

Browse files
loganthomassvekars
andauthored
FIX: Redirect old Loading data in PyTorch to newer Datasets & DataLoaders (#2922)
* add redirect to data tutorial --------- Co-authored-by: Svetlana Karslioglu <[email protected]>
1 parent 7a44230 commit 63f987d

File tree

6 files changed

+41
-210
lines changed

6 files changed

+41
-210
lines changed

Diff for: .jenkins/validate_tutorials_built.py

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"prototype_source/nestedtensor",
3838
"recipes_source/recipes/saving_and_loading_models_for_inference",
3939
"recipes_source/recipes/saving_multiple_models_in_one_file",
40-
"recipes_source/recipes/loading_data_recipe",
4140
"recipes_source/recipes/tensorboard_with_pytorch",
4241
"recipes_source/recipes/what_is_state_dict",
4342
"recipes_source/recipes/profiler_recipe",

Diff for: recipes_source/loading_data_recipe.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Loading data in PyTorch
2+
=======================
3+
4+
The content is deprecated. See `Datasets & DataLoaders <https://pytorch.org/tutorials/beginner/basics/data_tutorial.html>`__ instead.
5+
6+
.. raw:: html
7+
8+
<meta http-equiv="Refresh" content="1; url='https://pytorch.org/tutorials/beginner/basics/data_tutorial.html'" />

Diff for: recipes_source/recipes/README.txt

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,58 @@
11
PyTorch Recipes
22
---------------------------------------------
3-
1. loading_data_recipe.py
4-
Loading Data in PyTorch
5-
https://pytorch.org/tutorials/recipes/recipes/loading_data_recipe.html
6-
7-
2. defining_a_neural_network.py
3+
1. defining_a_neural_network.py
84
Defining a Neural Network in PyTorch
95
https://pytorch.org/tutorials/recipes/recipes/defining_a_neural_network.html
106

11-
3. what_is_state_dict.py
7+
2. what_is_state_dict.py
128
What is a state_dict in PyTorch
139
https://pytorch.org/tutorials/recipes/recipes/what_is_state_dict.html
1410

15-
4. saving_and_loading_models_for_inference.py
11+
3. saving_and_loading_models_for_inference.py
1612
Saving and loading models for inference in PyTorch
1713
https://pytorch.org/tutorials/recipes/recipes/saving_and_loading_models_for_inference.html
1814

19-
5. custom_dataset_transforms_loader.py
15+
4. custom_dataset_transforms_loader.py
2016
Developing Custom PyTorch Dataloaders
2117
https://pytorch.org/tutorials/recipes/recipes/custom_dataset_transforms_loader.html
2218

2319

24-
6. Captum_Recipe.py
20+
5. Captum_Recipe.py
2521
Model Interpretability using Captum
2622
https://pytorch.org/tutorials/recipes/recipes/Captum_Recipe.html
2723

28-
7. dynamic_quantization.py
24+
6. dynamic_quantization.py
2925
Dynamic Quantization
3026
https://pytorch.org/tutorials/recipes/recipes/dynamic_quantization.html
3127

32-
8. save_load_across_devices.py
28+
7. save_load_across_devices.py
3329
Saving and loading models across devices in PyTorch
3430
https://pytorch.org/tutorials/recipes/recipes/save_load_across_devices.html
3531

36-
9. saving_and_loading_a_general_checkpoint.py
32+
8. saving_and_loading_a_general_checkpoint.py
3733
Saving and loading a general checkpoint in PyTorch
3834
https://pytorch.org/tutorials/recipes/recipes/saving_and_loading_a_general_checkpoint.html
3935

40-
10. saving_and_loading_models_for_inference.py
36+
9. saving_and_loading_models_for_inference.py
4137
Saving and loading models for inference in PyTorch
4238
https://pytorch.org/tutorials/recipes/recipes/saving_and_loading_models_for_inference.html
4339

44-
11. saving_multiple_models_in_one_file.py
40+
10. saving_multiple_models_in_one_file.py
4541
Saving and loading multiple models in one file using PyTorch
4642
https://pytorch.org/tutorials/recipes/recipes/saving_multiple_models_in_one_file.html
4743

48-
12. warmstarting_model_using_parameters_from_a_different_model.py
44+
11. warmstarting_model_using_parameters_from_a_different_model.py
4945
Warmstarting models using parameters from different model
5046
https://pytorch.org/tutorials/recipes/recipes/warmstarting_model_using_parameters_from_a_different_model.html
5147

52-
13. zeroing_out_gradients.py
48+
12. zeroing_out_gradients.py
5349
Zeroing out gradients
5450
https://pytorch.org/tutorials/recipes/recipes/zeroing_out_gradients.html
5551

56-
14. mobile_perf.py
52+
13. mobile_perf.py
5753
PyTorch Mobile Performance Recipes
5854
https://pytorch.org/tutorials/recipes/mobile_perf.html
5955

60-
15. amp_recipe.py
56+
14. amp_recipe.py
6157
Automatic Mixed Precision
6258
https://pytorch.org/tutorials/recipes/amp_recipe.html

Diff for: recipes_source/recipes/loading_data_recipe.py

-163
This file was deleted.

Diff for: recipes_source/recipes/zeroing_out_gradients.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@
4444
######################################################################
4545
# Steps
4646
# -----
47-
#
47+
#
4848
# Steps 1 through 4 set up our data and neural network for training. The
4949
# process of zeroing out the gradients happens in step 5. If you already
5050
# have your data and neural network built, skip to 5.
51-
#
51+
#
5252
# 1. Import all necessary libraries for loading our data
5353
# 2. Load and normalize the dataset
5454
# 3. Build the neural network
5555
# 4. Define the loss function
5656
# 5. Zero the gradients while training the network
57-
#
57+
#
5858
# 1. Import necessary libraries for loading our data
5959
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60-
#
60+
#
6161
# For this recipe, we will just be using ``torch`` and ``torchvision`` to
6262
# access the dataset.
63-
#
63+
#
6464

6565
import torch
6666

@@ -76,10 +76,10 @@
7676
######################################################################
7777
# 2. Load and normalize the dataset
7878
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79-
#
79+
#
8080
# PyTorch features various built-in datasets (see the Loading Data recipe
8181
# for more information).
82-
#
82+
#
8383

8484
transform = transforms.Compose(
8585
[transforms.ToTensor(),
@@ -102,10 +102,10 @@
102102
######################################################################
103103
# 3. Build the neural network
104104
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105-
#
105+
#
106106
# We will use a convolutional neural network. To learn more see the
107107
# Defining a Neural Network recipe.
108-
#
108+
#
109109

110110
class Net(nn.Module):
111111
def __init__(self):
@@ -130,9 +130,9 @@ def forward(self, x):
130130
######################################################################
131131
# 4. Define a Loss function and optimizer
132132
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
133-
#
133+
#
134134
# Let’s use a Classification Cross-Entropy loss and SGD with momentum.
135-
#
135+
#
136136

137137
net = Net()
138138
criterion = nn.CrossEntropyLoss()
@@ -142,14 +142,14 @@ def forward(self, x):
142142
######################################################################
143143
# 5. Zero the gradients while training the network
144144
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145-
#
145+
#
146146
# This is when things start to get interesting. We simply have to loop
147147
# over our data iterator, and feed the inputs to the network and optimize.
148-
#
148+
#
149149
# Notice that for each entity of data, we zero out the gradients. This is
150150
# to ensure that we aren’t tracking any unnecessary information when we
151151
# train our neural network.
152-
#
152+
#
153153

154154
for epoch in range(2): # loop over the dataset multiple times
155155

@@ -181,13 +181,13 @@ def forward(self, x):
181181
# You can also use ``model.zero_grad()``. This is the same as using
182182
# ``optimizer.zero_grad()`` as long as all your model parameters are in
183183
# that optimizer. Use your best judgment to decide which one to use.
184-
#
184+
#
185185
# Congratulations! You have successfully zeroed out gradients PyTorch.
186-
#
186+
#
187187
# Learn More
188188
# ----------
189-
#
189+
#
190190
# Take a look at these other recipes to continue your learning:
191-
#
192-
# - `Loading data in PyTorch <https://pytorch.org/tutorials/recipes/recipes/loading_data_recipe.html>`__
191+
#
192+
# - `Loading data in PyTorch <https://pytorch.org/tutorials/beginner/basics/data_tutorial.html>`__
193193
# - `Saving and loading models across devices in PyTorch <https://pytorch.org/tutorials/recipes/recipes/save_load_across_devices.html>`__

Diff for: recipes_source/recipes_index.rst

-9
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ Recipes are bite-sized, actionable examples of how to use specific PyTorch featu
3030
3131
.. Basics
3232
33-
.. customcarditem::
34-
:header: Loading data in PyTorch
35-
:card_description: Learn how to use PyTorch packages to prepare and load common datasets for your model.
36-
:image: ../_static/img/thumbnails/cropped/loading-data.PNG
37-
:link: ../recipes/recipes/loading_data_recipe.html
38-
:tags: Basics
39-
40-
4133
.. customcarditem::
4234
:header: Defining a Neural Network
4335
:card_description: Learn how to use PyTorch's torch.nn package to create and define a neural network for the MNIST dataset.
@@ -407,7 +399,6 @@ Recipes are bite-sized, actionable examples of how to use specific PyTorch featu
407399
.. toctree::
408400
:hidden:
409401

410-
/recipes/recipes/loading_data_recipe
411402
/recipes/recipes/defining_a_neural_network
412403
/recipes/torch_logs
413404
/recipes/recipes/what_is_state_dict

0 commit comments

Comments
 (0)