💡 [REQUEST] - Tutorial: Visualizing the Mathematics Behind Neural Network Training
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- python, pytorch
調査の方向性
beginner_source/ から始め、autogradqs_tutorial.py、autograd_tutorial.py、buildmodel_tutorial.py を比較して、残っている学習上のギャップを特定します。提案された6つのセクションをカバーする CPU で実行可能なチュートリアルを作成し、観測可能な行列演算、勾配、grad_fn、オプティマイザーの変更を含めます。数学的な手順をコードで追跡および検証できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
🚀 Describe the improvement or the new tutorial
A beginner-friendly tutorial that traces the mathematical operations inside a PyTorch training loop — connecting linear algebra to torch.nn.Linear, the chain rule to torch.autograd.backward(), and gradient descent to torch.optim — with runnable code that makes each step observable and verifiable.
Why this is needed:
Many learners use autograd as a black box. Existing tutorials explain the API (how to call .backward(), how to access .grad) but do not trace what is happening mathematically at each step. This tutorial bridges that gap by making the math visible through code:
- Print a weight matrix, verify it matches x @ W.T + b
- Call .backward(), then manually verify the gradient using the chain rule
- Walk the grad_fn graph to see the operations autograd recorded
- Compare parameters before and after optimizer.step() to see gradient descent in action
Proposed structure:
- Linear Algebra — what nn.Linear computes, verified with manual matrix multiplication
- Activation Functions — why nonlinearity matters, visualizing ReLU gradients
- The Chain Rule — what backward() computes, manually verifying gradients
- The Computational Graph — inspecting grad_fn to trace operations
- Gradient Descent — what optimizer.step() does, before/after comparison
- Putting It Together — forward, backward, step mapped to three branches of mathematics
This approach has been validated in practice: I presented this material at Grace Hopper Celebration 2025 ("The Math Behind the Magic: Understanding the Role of Mathematics in Deep Learning"). Talk materials: https://github.com/AddyM/Math_behind_ML
Difficulty level: Beginner
Target location: beginner_source/
I am happy to write and submit this tutorial as a PR.
Existing tutorials on this topic
-
autogradqs_tutorial.py — covers autograd API usage (requires_grad, backward, grad). Focuses on how to use autograd, not what it computes mathematically.
https://pytorch.org/tutorials/beginner/basics/autogradqs_tutorial.html -
autograd_tutorial.py — conceptual overview of automatic differentiation and computational graphs. Does not include manual verification of gradients or tracing the chain rule step by step.
https://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html -
buildmodel_tutorial.py — covers nn.Module and model building. Does not connect layer operations to their underlying linear algebra.
https://pytorch.org/tutorials/beginner/basics/buildmodel_tutorial.html
Additional context
PyTorch's eager execution model makes the mathematics of deep learning observable in a way static graph frameworks do not allow. This tutorial leans into that strength — every intermediate result is printable, every gradient is inspectable, every operation in the computational graph is traceable.
No GPU required — the entire tutorial runs on CPU, making it accessible to all learners.
References:
GHC 2025 talk materials: https://github.com/AddyM/Math_behind_ML
PyTorch Discuss thread on this approach: https://discuss.pytorch.org/ (search: "Building a PyTorch curriculum that teaches math through code")
- 主要言語
- Python
- スター
- 9.3k
- フォーク
- 4.4k
- 平均マージ
- 1日 21時間
- マージ済み PR(30日)
- 4
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytorch/tutorials のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
pytorch/tutorials の issue をすべて見る
似ている issue
-
area: harness bug status: needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Human-Agent-Society/reef#625 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
learningequality/kolibri#15351 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Name consistency オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
eellak/triplestore#65 · コメント 1 件 ·