In a small computation graph, input feeds two branches that share the same weight : and , and the loss is . How do you compute by backpropagation, and what happens if an implementation overwrites instead of accumulating branch gradients?
Deep learning, Backpropagation
Level L2 Elementary. Length Short. Nature Mat Mathematical.
What's being asked
Whether you apply the multivariable chain rule (summing upstream contributions at fan-out nodes) when one parameter appears in multiple paths.
Key idea
When a node fans out into two branches and , backpropagation sums the gradients arriving along all paths: . Here that gives .
Steps
- Forward pass at : , , product , and .
- Upstream gradients to and : , so and .
- Local derivatives with respect to : and .
- Accumulate both paths: . If code overwrites the stored gradient instead of adding to it, one branch’s gradient is silently lost (returning or instead of ).
Common mistakes
- Dropping one branch when differentiating with respect to , which happens whenever weight sharing occurs (RNNs, CNNs, tied embeddings).
- Multiplying the two branch gradients instead of adding them.
How long your answer should be
4–5 lines with the forward values and summed chain rule.
Read this
Previous in Deep learning: How can a two-layer MLP with two ReLU hidden units and a linear output unit compute the XOR function on , and what values do its hidden units and output take on all four inputs?
Next in Deep learning: A hidden layer with independent inputs (each of mean and variance ) computes with zero bias, which gives when weights are drawn independently with mean and variance . What is the standard deviation of under () versus Xavier-style normal (), and why does stall training under a activation?