Reverse-Mode Automatic Differentiation

Propagate sensitivities backward through a graph and add contributions when a value reaches the loss through several paths.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Store the local information needed by the chain rule
  2. Work and saved state have separate costs

Store the local information needed by the chain rule

For \(u=x^2,v=u+x\), start with derivative of \(v\) with respect to itself equal to one. The addition sends one to \(u\) and directly to \(x\). Squaring sends \(2x\) times the incoming derivative from \(u\) to \(x\). Adding both contributions gives \(2x+1\). Reverse topological order processes all uses before propagating through their definition.

Work and saved state have separate costs

A scalar loss can receive gradients for many parameters in one reverse sweep. The sweep may need forward intermediates, so retaining them can cost substantial memory. Recomputing selected values trades extra work for less saved state, provided repeated execution has the required semantics. Topological order gives the dependency ordering. Differentiable rendering illustrates models where visibility changes need derivatives beyond ordinary smooth operations.[1]

References

  1. Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning ↩