Learn Before
Concept

Detaching Computation

During automatic differentiation, it is sometimes necessary to exclude specific calculations from the recorded computational graph. This is often required when inputs generate auxiliary intermediate variables that should not contribute to the gradient computation. To achieve this, the computational graph associated with these intermediate terms is detached from the final result. A new variable is instantiated with the same numerical value, but its provenance—the record of operations that created it—is completely erased. Consequently, this new variable acts as a constant with no ancestors in the graph, preventing gradients from flowing back through it to earlier variables.

0

1

Updated 2026-05-02

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L