chickadee » nanograd » clip-gradients-by-norm!

clip-gradients-by-norm! parameters max-normprocedure

If the global L2 norm is larger than max-norm, scales all gradients so that it equals max-norm, which keeps their direction. Returns the norm before clipping.