💡 [REQUEST] - Tutorial: Visualizing the Mathematics Behind Neural Network Training
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- python, pytorch
- Lĩnh vực
- documentation, machine-learning
Hướng nghiên cứu
Bắt đầu trong beginner_source/ và so sánh autogradqs_tutorial.py, autograd_tutorial.py và buildmodel_tutorial.py để xác định khoảng trống hướng dẫn còn lại. Xây dựng một tutorial có thể chạy trên CPU, bao quát sáu phần được đề xuất, bao gồm các phép toán ma trận có thể quan sát, gradient, grad_fn và các thay đổi của optimizer. Công việc được xem là hoàn thành khi các bước toán học có thể được lần theo và kiểm chứng trong code.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🚀 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")
- Ngôn ngữ chính
- Python
- Star
- 9.3k
- Fork
- 4.4k
- Merge trung bình
- 1 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 4
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pytorch/tutorials
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Tất cả issue của pytorch/tutorials
Issue tương tự
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Đang mởarea: harness bug status: needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Human-Agent-Society/reef#625 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
learningequality/kolibri#15351 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Name consistency Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
eellak/triplestore#65 · 1 bình luận ·