Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#3,907 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

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

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:

  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")

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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pytorch/tutorials

Tất cả issue của pytorch/tutorials

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.