Skip to main content

Module utils

Module utils 

Source

Functionsยง

clip_gradient_norm
Clip gradient norm (global gradient clipping)
clip_gradients
Clip gradient values to a specified range
gradient_centralization
Compute gradient centralization
scalar_opt
Convert a value into the generic float type A, or None when A cannot represent it.
scalar_or
Convert an f64 value into the generic float type A, falling back to fallback when A cannot represent it.
total_order
Total ordering for floating-point values that never panics.
try_f64
Convert a generic float A down into f64, returning an honest error when the value has no f64 representation.
try_scalar
Convert an f64 value into the generic float type A, returning an honest error when A cannot represent it.
try_scalar_str
try_scalar for the call sites whose error type is String.
zero_small_gradients
Zero out small gradient values