Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Redirect old Loading data in PyTorch to newer Datasets & DataLoaders #2922

Merged
merged 19 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .jenkins/validate_tutorials_built.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"prototype_source/nestedtensor",
"recipes_source/recipes/saving_and_loading_models_for_inference",
"recipes_source/recipes/saving_multiple_models_in_one_file",
"recipes_source/recipes/loading_data_recipe",
"recipes_source/recipes/tensorboard_with_pytorch",
"recipes_source/recipes/what_is_state_dict",
"recipes_source/recipes/profiler_recipe",
Expand Down
8 changes: 8 additions & 0 deletions recipes_source/loading_data_recipe.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Loading data in PyTorch
=======================

The content is deprecated. See `Datasets & DataLoaders <https://pytorch.org/tutorials/beginner/basics/data_tutorial.html>`__ instead.

.. raw:: html

<meta http-equiv="Refresh" content="1; url='https://pytorch.org/tutorials/beginner/basics/data_tutorial.html'" />
32 changes: 14 additions & 18 deletions recipes_source/recipes/README.txt
Original file line number Diff line number Diff line change
@@ -1,62 +1,58 @@
PyTorch Recipes
---------------------------------------------
1. loading_data_recipe.py
Loading Data in PyTorch
https://pytorch.org/tutorials/recipes/recipes/loading_data_recipe.html

2. defining_a_neural_network.py
1. defining_a_neural_network.py
Defining a Neural Network in PyTorch
https://pytorch.org/tutorials/recipes/recipes/defining_a_neural_network.html

3. what_is_state_dict.py
2. what_is_state_dict.py
What is a state_dict in PyTorch
https://pytorch.org/tutorials/recipes/recipes/what_is_state_dict.html

4. saving_and_loading_models_for_inference.py
3. saving_and_loading_models_for_inference.py
Saving and loading models for inference in PyTorch
https://pytorch.org/tutorials/recipes/recipes/saving_and_loading_models_for_inference.html

5. custom_dataset_transforms_loader.py
4. custom_dataset_transforms_loader.py
Developing Custom PyTorch Dataloaders
https://pytorch.org/tutorials/recipes/recipes/custom_dataset_transforms_loader.html


6. Captum_Recipe.py
5. Captum_Recipe.py
Model Interpretability using Captum
https://pytorch.org/tutorials/recipes/recipes/Captum_Recipe.html

7. dynamic_quantization.py
6. dynamic_quantization.py
Dynamic Quantization
https://pytorch.org/tutorials/recipes/recipes/dynamic_quantization.html

8. save_load_across_devices.py
7. save_load_across_devices.py
Saving and loading models across devices in PyTorch
https://pytorch.org/tutorials/recipes/recipes/save_load_across_devices.html

9. saving_and_loading_a_general_checkpoint.py
8. saving_and_loading_a_general_checkpoint.py
Saving and loading a general checkpoint in PyTorch
https://pytorch.org/tutorials/recipes/recipes/saving_and_loading_a_general_checkpoint.html

10. saving_and_loading_models_for_inference.py
9. saving_and_loading_models_for_inference.py
Saving and loading models for inference in PyTorch
https://pytorch.org/tutorials/recipes/recipes/saving_and_loading_models_for_inference.html

11. saving_multiple_models_in_one_file.py
10. saving_multiple_models_in_one_file.py
Saving and loading multiple models in one file using PyTorch
https://pytorch.org/tutorials/recipes/recipes/saving_multiple_models_in_one_file.html

12. warmstarting_model_using_parameters_from_a_different_model.py
11. warmstarting_model_using_parameters_from_a_different_model.py
Warmstarting models using parameters from different model
https://pytorch.org/tutorials/recipes/recipes/warmstarting_model_using_parameters_from_a_different_model.html

13. zeroing_out_gradients.py
12. zeroing_out_gradients.py
Zeroing out gradients
https://pytorch.org/tutorials/recipes/recipes/zeroing_out_gradients.html

14. mobile_perf.py
13. mobile_perf.py
PyTorch Mobile Performance Recipes
https://pytorch.org/tutorials/recipes/mobile_perf.html

15. amp_recipe.py
14. amp_recipe.py
Automatic Mixed Precision
https://pytorch.org/tutorials/recipes/amp_recipe.html
163 changes: 0 additions & 163 deletions recipes_source/recipes/loading_data_recipe.py

This file was deleted.

38 changes: 19 additions & 19 deletions recipes_source/recipes/zeroing_out_gradients.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@
######################################################################
# Steps
# -----
#
#
# Steps 1 through 4 set up our data and neural network for training. The
# process of zeroing out the gradients happens in step 5. If you already
# have your data and neural network built, skip to 5.
#
#
# 1. Import all necessary libraries for loading our data
# 2. Load and normalize the dataset
# 3. Build the neural network
# 4. Define the loss function
# 5. Zero the gradients while training the network
#
#
# 1. Import necessary libraries for loading our data
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#
# For this recipe, we will just be using ``torch`` and ``torchvision`` to
# access the dataset.
#
#

import torch

Expand All @@ -76,10 +76,10 @@
######################################################################
# 2. Load and normalize the dataset
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#
# PyTorch features various built-in datasets (see the Loading Data recipe
# for more information).
#
#

transform = transforms.Compose(
[transforms.ToTensor(),
Expand All @@ -102,10 +102,10 @@
######################################################################
# 3. Build the neural network
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#
# We will use a convolutional neural network. To learn more see the
# Defining a Neural Network recipe.
#
#

class Net(nn.Module):
def __init__(self):
Expand All @@ -130,9 +130,9 @@ def forward(self, x):
######################################################################
# 4. Define a Loss function and optimizer
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#
# Let’s use a Classification Cross-Entropy loss and SGD with momentum.
#
#

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

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

Expand Down Expand Up @@ -181,13 +181,13 @@ def forward(self, x):
# You can also use ``model.zero_grad()``. This is the same as using
# ``optimizer.zero_grad()`` as long as all your model parameters are in
# that optimizer. Use your best judgment to decide which one to use.
#
#
# Congratulations! You have successfully zeroed out gradients PyTorch.
#
#
# Learn More
# ----------
#
#
# Take a look at these other recipes to continue your learning:
#
# - `Loading data in PyTorch <https://pytorch.org/tutorials/recipes/recipes/loading_data_recipe.html>`__
#
# - `Loading data in PyTorch <https://pytorch.org/tutorials/beginner/basics/data_tutorial.html>`__
# - `Saving and loading models across devices in PyTorch <https://pytorch.org/tutorials/recipes/recipes/save_load_across_devices.html>`__
9 changes: 0 additions & 9 deletions recipes_source/recipes_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ Recipes are bite-sized, actionable examples of how to use specific PyTorch featu

.. Basics

.. customcarditem::
:header: Loading data in PyTorch
:card_description: Learn how to use PyTorch packages to prepare and load common datasets for your model.
:image: ../_static/img/thumbnails/cropped/loading-data.PNG
:link: ../recipes/recipes/loading_data_recipe.html
:tags: Basics


.. customcarditem::
:header: Defining a Neural Network
:card_description: Learn how to use PyTorch's torch.nn package to create and define a neural network for the MNIST dataset.
Expand Down Expand Up @@ -407,7 +399,6 @@ Recipes are bite-sized, actionable examples of how to use specific PyTorch featu
.. toctree::
:hidden:

/recipes/recipes/loading_data_recipe
/recipes/recipes/defining_a_neural_network
/recipes/torch_logs
/recipes/recipes/what_is_state_dict
Expand Down
Loading