core/optim/grad_utils library

Gradient regularization utilities.

Functions

clipGradNorm(List<Tensor> parameters, double maxNorm) double
Clip the global L2 norm of the gradients across parameters to at most maxNorm, in place. Returns the pre-clip total norm — useful for logging.