Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

💡 [REQUEST] - Tutorial: Visualizing the Mathematics Behind Neural Network Training

オープン
#3,907 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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:

  1. Print a weight matrix, verify it matches x @ W.T + b
  2. Call .backward(), then manually verify the gradient using the chain rule
  3. Walk the grad_fn graph to see the operations autograd recorded
  4. Compare parameters before and after optimizer.step() to see gradient descent in action

Proposed structure:

  1. Linear Algebra — what nn.Linear computes, verified with manual matrix multiplication
  2. Activation Functions — why nonlinearity matters, visualizing ReLU gradients
  3. The Chain Rule — what backward() computes, manually verifying gradients
  4. The Computational Graph — inspecting grad_fn to trace operations
  5. Gradient Descent — what optimizer.step() does, before/after comparison
  6. 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
  1. 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

  2. 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

  3. 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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pytorch/tutorials のほかの issue

pytorch/tutorials の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。