Computational graphs
A computational graph represents elementary operations as nodes connected by their input dependencies.
On this page 8 sections
01Understand the idea#
A computational graph breaks a formula into small operations connected by their dependencies. It shows which intermediate values must exist before later values can be computed. Training systems use the same dependency structure to propagate derivatives backward.
A computational graph names the small operations inside an expression. Each arrow points from an input value to an operation that uses it.
For , first name the sum . Then write . The square receives , so the edge runs from to .
These node equations also describe the graph in text: every variable on the right is an incoming dependency.
For , create a node and then a node . At , the first node gives 5 and the next gives 25. The edge from to the square means the square consumes . An edge is a dependency, not an instruction to add the two node labels.
Represent . Choose node equations.
Show answer and explanation
The square uses the sum .
02Operation order changes the expression#
Operation order changes the expression. Squaring first and then adding gives . To represent , the add node must come first.
Each node can be one small operation. A whole model layer is not required.
Square input , then multiply the result by . Choose nodes for .
Show answer and explanation
Multiply the squared result by the fixed factor.
03A value may feed more than one operation#
A value may feed more than one operation. For , write and . The input feeds both the addition and the final multiplication.
Substitute the intermediate node into the output node to check that the graph represents the intended formula.
Target: . A graph uses ; . Choose the repaired graph.
Show answer and explanation
The output multiplies original by sum .
04If an intermediate result is reused, draw its outgoing edges from the same node#
If an intermediate result is reused, draw its outgoing edges from the same node. That shared node matters later: its effect on a loss includes every downstream use. Replacing a dependency graph with the written order of symbols can hide those shared paths.
Name the operations and connect each node to the inputs it uses.
- Represent a scalar expression as a directed graph of elementary operations.
Sources & further reading
- [1]Stanford CS231n: Backpropagation ↗Stanford CS231n · Article