TorchLean API

NN.Runtime.Autograd.Engine.Core.Backward

CPU gradient maps #

The reverse sweeps themselves live with the tape in NN.Runtime.Autograd.Engine.Tape. These helpers turn a CPU sweep's result into the sparse map that training code reads.

Convert the optional dense gradient array returned by backwardDense into a sparse HashMap.

Only entries that are present (some (some g)) are kept. The result records exactly the nodes reached by reverse-mode propagation.

Instances For

    Reverse-mode backpropagation returning a HashMap of only the nodes that received gradients.

    This is the sparse public form of backwardDense: it computes dense gradients first, then drops nodes that did not receive a gradient.

    Instances For

      Backpropagate from a scalar output with seed gradient 1.

      PyTorch analogy: loss.backward() when loss is a scalar.

      Instances For