CHAPTER 9Algorithmic Adjoint Differentiation

In this second introductory chapter, we discuss in detail how to automatically generate calculation graphs and conduct adjoint calculations through them to produce all the differentials of any calculation code in constant time, automatically and in a noninvasive manner.

We consider a mathematical calculation that takes a number of scalar inputs images and produces a scalar output images. We assume that the calculation is written in C++ (including perhaps nested function calls, overwriting of variables, control flow, and object manipulation). Our goal is to differentiate this calculation code in constant time, like we did in the previous chapter, but automatically. For this purpose, we develop AAD code, that is, code that runs adjoint differentiation over any calculation code. In order to do that, the AAD code must understand the sequence of operations involved in the calculation code, a notion known to programmers as “meta-programming” or “introspection.” It is achieved through operator overloading, whereby all mathematical operators and functions are replaced by custom code when applied to specific types, as opposed to native C++ types like images. So the ...

Get Modern Computational Finance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.