(rontolisp) docs
← Functions

torch:zero-grad

(torch:zero-grad tensor-or-module)

Clears accumulated gradients (back to nil) and returns the argument: for a tensor its own gradient, for a module the gradient of every parameter torch:parameters reaches. Because torch:backward accumulates (+=), a training loop calls this on its model between steps.