計算グラフ:局所微分と逆方向の累積
予測と観察の証拠を記録した後にのみ支援を利用できる。
前提条件
Day 19-20 の連鎖律と勾配ドリル。不安なステップがあれば、まず Day レベルの回復リンクを開くこと。
学習目標
スカラー式を計算グラフに分解し、各ノードの前向きの値を計算してから、局所的な連鎖律の因子を掛けて導関数を逆方向に伝播させる。
手順
L = (a*b + c)^2 で a = 2, b = 3, c = 1 とする。前向き:n1 = a*b = 6、n2 = n1 + c = 7、L = n2^2 = 49。逆方向:dL/dn2 = 2*n2 = 14、dL/dn1 = 14 * ∂n2/∂n1 = 14 * 1 = 14、dL/dc = 14 * ∂n2/∂c = 14、dL/da = 14 * ∂n1/∂a = 14 * b = 42、dL/db = 14 * ∂n1/∂b = 14 * a = 28。各ステップは 1 つの局所エッジに適用した Day 19-20 の連鎖律である。コードで a を摂動する前に dL/da を予測せよ。
演習と予測記録
(2, 3, 1) での L = (a*b + c)^2 のグラフを描き、前向きの値 6, 7, 49 を埋め、すべての入力勾配を手計算せよ。dL/da, dL/db, dL/dc を中心有限差分で検証し、一致を記録せよ。
逆モード:n2 での随伴値は、そこに入る前向きエッジ n1->n2 と c->n2 を逆方向にたどって n1 と c へ届く。ゆえに dL/dn2 = dL/dn1 = dL/dc = 14。局所因子を適用すると入力勾配は dL/da = 42、dL/db = 28、dL/dc = 14。
前向き:n1 = 6、n2 = 7、L = 49。逆方向:dL/dn2 = 14、dL/dn1 = 14、dL/dc = 14、dL/da = 14*3 = 42、dL/db = 14*2 = 28。有限差分(h = 1e-5 で (L(2+h,3,1) - L(2-h,3,1)) / 2h、b, c も同様)は約 42.0000, 28.0000, 14.0000 を返す。これは micrograd 型エンジンが各入力の .grad に報告するのと同じ数値である。
助けなしで前向きの値 6, 7, 49 と逆方向の値 42, 28, 14 を再現し、すべてのエッジで局所微分を言え、自分の有限差分実行が各手計算勾配と一致する。
公式ソースリソースと権利証跡
micrograd: A tiny scalar-valued autograd engine
該当セクション・タイムスタンプ: micrograd/engine.py: class Value (_backward closures and backward() topological sort); README 'Example usage'
検証バージョンと日付: 2022 (verified 2026-10-30)
The scalar computational graph in this lesson is exactly the micrograd engine walkthrough; it previews the autograd project without importing any material.
Chain rule and partial derivatives (Study Days 19-20).
The full forward and backward pass is derived locally with numeric verification; no video is required.
比較対象候補リソースと選定評価 (2)
Normative production documentation, but micrograd's pure Python implementation provides far superior initial clarity.
High visual quality, pairs cleanly as optional supplementary visual reference.
OpenStax Calculus Volume 3
該当セクション・タイムスタンプ: Section 4.5: tree-diagram rule used to justify backward accumulation
検証バージョンと日付: OpenStax Calculus Volume 3 web edition (verified 2026-10-30)
Provides the formal chain rule statement that the graph walkthrough applies node by node.
Scalar chain rule (day-19) and partial derivatives (day-20).
The derivation uses only local rules already proven on Days 19-20.
比較対象候補リソースと選定評価 (2)
Selected as the lecture-depth companion for partial derivatives; OpenStax Volume 3 remains the written primary reference.
Strong visual coverage of gradients, but the OpenStax text better matches the lesson's theorem-plus-hand-check structure.