Learn Before
Concept

Automatic Differentiation with Dynamic Control Flow

One of the major benefits of automatic differentiation is its ability to compute gradients even when the sequence of operations depends on dynamic control flow, such as Python if statements, while loops, and arbitrary function calls. Since the exact path of computation is not known a priori, the computational graph is realized dynamically only during the forward evaluation on a specific input. Once this specific graph is constructed, deep learning frameworks can execute the backward pass to accurately calculate the gradient of the resulting variable.

0

1

Updated 2026-05-02

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L