Forward evaluation
Forward evaluation computes each graph operation after all of its input values are known.
On this page 8 sections
01A forward pass evaluates a computation from known inputs to outputs#
A forward pass evaluates a computation from known inputs to outputs. At every operation, substitute the values produced by its input nodes. Storing these intermediate results makes a complicated calculation traceable and supplies the values needed to evaluate derivatives later.
A forward pass computes the graph’s values. Start with known inputs; evaluate a node only after every value it uses is available.
Here , , and . Compute first. The square then receives , giving .
Squaring the original would give , which evaluates a different expression.
For , , and at , calculate before . Then compute . The shared value is used twice. Replacing the second use with the original input 2 would change the function.
and . At , find .
Show answer and explanation
First ; then .
02Branches may be evaluated in either order if they do not depend on each other#
Branches may be evaluated in either order if they do not depend on each other. With , , , and , compute and before the join.
A score uses , , and . At , find .
Show answer and explanation
Compute both branches: and . Their sum is .
03The dependency arrows decide what comes next#
The dependency arrows decide what comes next. A node needs its immediate inputs, even if the expression contains the same original variable several times.
Keep each intermediate value until all of its consumers have used it.
and . At , a learner uses . Repair the final value .
Show answer and explanation
First ; then .
04A closer look#
Before debugging a gradient, check that the forward pass computes the intended prediction and loss. A perfectly implemented derivative of the wrong computation still trains the wrong model. Each stored value belongs to the current input and parameter setting.
Follow the dependencies and use each computed intermediate value.
- Evaluate a small computational graph in dependency order.
Sources & further reading
- [1]Stanford CS231n: Backpropagation ↗Stanford CS231n · Article