Calculus
The purpose of backpropagation is to determine how the network's parameters contributed to the final loss.
From Loss to Learning Information
A neural network can be viewed as a sequence of connected operations. One operation produces an output that becomes the input to another operation, and the final result produces a loss value. Backpropagation is the algorithm that starts with this final loss and works backward through the connected operations to compute gradient values.
The purpose of backpropagation is to determine how the network's parameters contributed to the final loss.
The Forward Route and Its Reverse
Imagine following the network in the order in which its operations are connected. An earlier operation produces a value, a later operation uses that value, and the final operation produces the loss. This is the forward nesting order: later operations depend on results produced earlier in the network.
Backpropagation is an algorithm for computing the gradient values of a neural network.
Why the Chain Rule Is Necessary
A network is not one isolated operation. It is built from connected operations, so an earlier value can affect the loss through the later operations that use it. To determine the effect of that earlier value, backpropagation must combine the derivative information from the later part of the network with the local derivative of the operation currently being examined. This is the role of the chain rule.
For a nested network, the backward traversal follows the reverse of the forward nesting order. At each operation, the information already obtained from later operations is combined with the local derivative of the current operation. Repeating this process carries gradient information toward earlier operations and their parameters.
Tracing One Parameter's Influence
Following a Parameter Backward
Trace how backpropagation determines the contribution of one parameter in an abstract connected network.
- 1Start at the loss
Begin with the final loss because it is the endpoint produced by the forward sequence of operations and the starting point for the backward traversal.
- 2Inspect the latest operation
Examine the operation immediately before the loss. Use the gradient information from the later part together with this operation's local derivative.
- 3Move toward earlier operations
Continue in reverse order through the connected operations. At each point, combine the information arriving from later operations with the local derivative of the current operation.
- 4Reach the parameter
When the backward traversal reaches the operation associated with the parameter, the accumulated gradient information describes how that parameter contributed to the final loss.
The parameter's contribution is determined by following the reverse route from the final loss and applying the chain-rule combination at each connected operation.
The important idea is not to inspect a parameter in isolation. Its contribution is determined by the entire connected route from that parameter to the final loss. Every later operation on that route contributes local derivative information that must be incorporated during the backward traversal.
Checking a Backpropagation Trace
- 1Begin at the final loss.
- 2Inspect the operation immediately before the loss.
- 3Move toward earlier operations in the reverse of the forward nesting order.
- 4At each operation, check that later gradient information is combined with the operation's local derivative.
- 5When a result diverges from what is expected, locate the first operation where that backward combination no longer follows the chain-rule structure.
Common Direction and Chain-Rule Errors
Common mistake Starting the backward calculation at the earliest operation.
What it looks likeInspecting the first operation before considering the final loss.
Why it failsBackpropagation starts with the final loss and moves backward toward earlier operations.
Do this insteadBegin at the final loss, then follow the reverse of the forward nesting order.
Common mistake Treating connected operations as if they were independent.
What it looks likeUsing only the local derivative of one operation without considering information from later operations.
Why it failsThe chain rule combines local derivatives of connected operations.
Do this insteadAt each operation, combine the derivative information from the later part of the network with the local derivative of the current operation.
Common mistake Stopping after examining the operation nearest to the loss.
What it looks likeComputing information for the top operation but never tracing it toward earlier operations or parameters.
Why it failsThe purpose of backpropagation is to determine how the network's parameters contributed to the loss.
Do this insteadContinue the reverse traversal until the relevant earlier operations and parameters have been reached.
Common mistake Looking only at the final result when checking a calculation.
What it looks likeSeeing that a gradient value is incorrect but not checking the intermediate backward combinations.
Why it failsA divergence can be localized to the first operation where the backward chain-rule structure stops being followed.
Do this insteadCheck the traversal one operation at a time, beginning at the final loss.
Practice the Reverse Trace
A network is described as three connected operations followed by a final loss. Explain the order in which backpropagation examines these operations, and describe what must be combined at each operation to determine the gradient information for an earlier parameter.
Hints
- Where does the backward traversal begin?
- What is the relationship between the forward nesting order and the backward order?
- What two kinds of derivative information are combined at each operation?
A complete answer should say that the traversal begins at the final loss, proceeds toward earlier operations in reverse order, and combines later gradient information with each current operation's local derivative.
What to Remember
- 1Backpropagation is an algorithm for computing gradient values in a neural network.
- 2A neural network can be understood as connected operations whose final result produces a loss.
- 3Backpropagation starts at the final loss and moves backward from later operations toward earlier ones.
- 4The chain rule combines local derivatives across connected operations.
- 5A parameter's contribution to the loss is determined by tracing the backward route from the loss through the operations connected to that parameter.
At a glance
- Backpropagation computes neural-network gradient values.
- It begins with the final loss and follows the reverse of the forward nesting order.
- The chain rule is required because operations are connected and an earlier value affects the loss through later operations.
- At each step, later gradient information is combined with the local derivative of the current operation.
- Following this process to a parameter determines how that parameter contributed to the final loss.