Skip to main content

backward

Function backward 

Source
pub fn backward(root: &Tensor) -> EtensorResult<Gradients>
Expand description

Triggers the backpropagation engine starting from the given root tensor (usually the Loss).

This function:

  1. Seeds the root tensor’s gradient with 1.0.
  2. Extracts the thread_local! Tape.
  3. Executes all recorded TapeActions in strict reverse order.
  4. Returns the fully populated Gradients map containing all derivatives.