From 677253782a0a9b78371c8854a3fbd4519ce9e791 Mon Sep 17 00:00:00 2001 From: Vineeth Bhat <35373409+FlightVin@users.noreply.github.com> Date: Sun, 4 Jan 2026 15:24:04 +0530 Subject: [PATCH 1/3] Clarify explanation of requires_grad in PyTorch --- beginner_source/nn_tutorial.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/beginner_source/nn_tutorial.py b/beginner_source/nn_tutorial.py index e04815bd27e..50249516323 100644 --- a/beginner_source/nn_tutorial.py +++ b/beginner_source/nn_tutorial.py @@ -110,9 +110,10 @@ # gradient. This causes PyTorch to record all of the operations done on the tensor, # so that it can calculate the gradient during back-propagation *automatically*! # -# For the weights, we set ``requires_grad`` **after** the initialization, since we -# don't want that step included in the gradient. (Note that a trailing ``_`` in -# PyTorch signifies that the operation is performed in-place.) +# We set ``requires_grad`` **after** the initialization math. If enabled earlier, +# PyTorch would view the weights as the result of a calculation (non-leaf) rather +# than a source parameter, making them impossible to optimize. (Note that a trailing +# ``_`` in PyTorch signifies that the operation is performed in-place.) # # .. note:: We are initializing the weights here with # `Xavier initialisation `_ From 207c0d3bb7fc13727f1310cae8dfeb9ed1f4c5b9 Mon Sep 17 00:00:00 2001 From: sekyondaMeta <127536312+sekyondaMeta@users.noreply.github.com> Date: Thu, 8 Jan 2026 10:49:06 -0500 Subject: [PATCH 2/3] Update nn_tutorial.py Fix broken links --- beginner_source/nn_tutorial.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beginner_source/nn_tutorial.py b/beginner_source/nn_tutorial.py index 50249516323..8516f06f641 100644 --- a/beginner_source/nn_tutorial.py +++ b/beginner_source/nn_tutorial.py @@ -31,7 +31,7 @@ # MNIST data setup # ---------------- # -# We will use the classic `MNIST `_ dataset, +# We will use the classic `MNIST `_ dataset, # which consists of black-and-white images of hand-drawn digits (between 0 and 9). # # We will use `pathlib `_ @@ -474,7 +474,7 @@ def get_model(): # walks through a nice example of creating a custom ``FacialLandmarkDataset`` class # as a subclass of ``Dataset``. # -# PyTorch's `TensorDataset `_ +# PyTorch's `TensorDataset `_ # is a Dataset wrapping tensors. By defining a length and way of indexing, # this also gives us a way to iterate, index, and slice along the first # dimension of a tensor. This will make it easier to access both the From dba5b9b676d06158212c5855b050f7f72626ff45 Mon Sep 17 00:00:00 2001 From: Vineeth Bhat <35373409+FlightVin@users.noreply.github.com> Date: Sun, 11 Jan 2026 14:45:15 +0530 Subject: [PATCH 3/3] Remove trailing spaces --- beginner_source/nn_tutorial.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beginner_source/nn_tutorial.py b/beginner_source/nn_tutorial.py index 8516f06f641..541767af573 100644 --- a/beginner_source/nn_tutorial.py +++ b/beginner_source/nn_tutorial.py @@ -110,9 +110,9 @@ # gradient. This causes PyTorch to record all of the operations done on the tensor, # so that it can calculate the gradient during back-propagation *automatically*! # -# We set ``requires_grad`` **after** the initialization math. If enabled earlier, -# PyTorch would view the weights as the result of a calculation (non-leaf) rather -# than a source parameter, making them impossible to optimize. (Note that a trailing +# We set ``requires_grad`` **after** the initialization math. If enabled earlier, +# PyTorch would view the weights as the result of a calculation (non-leaf) rather +# than a source parameter, making them impossible to optimize. (Note that a trailing # ``_`` in PyTorch signifies that the operation is performed in-place.) # # .. note:: We are initializing the weights here with