Derivatives with a Computation Graph#
Stage 3 · 📉 Derivatives & the Computation Graph · Lesson 12 of 17 · intermediate
◀ Previous · Computation Graph · Next · Logistic Regression Gradient Descent ▶ · ↑ Section
Important
✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.
Walking backward#
With the forward pass done, the backward pass computes derivatives by moving right to left through the same graph, applying the chain rule at each node. This right-to-left sweep is exactly what backpropagation does.
One step at a time#
Start at the output. Since \(J = 3v\), nudging \(v\) moves \(J\) three times as much, so \(\partial J / \partial v = 3\). Step back through \(v = a + u\):
Then back through \(u = bc\):
using \(a = 5, b = 3, c = 2\).
The dvar convention#
A coding shorthand runs through the whole course: the variable named ``dvar`` always means “the
derivative of the final output \(J\) with respect to \(\text{var}\)”. So dv is
\(\partial J / \partial v\), da is \(\partial J / \partial a\), du is
\(\partial J / \partial u\), and so on — every d-something is a gradient of the same target,
which keeps the code readable.
Reuse is the point#
Notice that \(\partial J / \partial v\) was computed once and then reused for both \(\partial J / \partial a\) and \(\partial J / \partial u\), and \(\partial J / \partial u\) was reused for \(b\) and \(c\). That reuse is why the backward pass is efficient: each node’s derivative follows from the one just downstream, so the whole gradient costs about as much as the forward pass. Applying this to the logistic-regression neuron is the next lesson.
Hint
Related lessons: Computation Graph · More Derivative Examples · Logistic Regression Gradient Descent · Gradient Descent on m Training Examples
See also
Source article Adapted (context, re-expressed) in our own words from: https://insightful-data-lab.com/2025/04/07/derivatives-with-a-computation-graph/ (insightful-data-lab.com).