Skip to main content

clip_grad_value_

Function clip_grad_value_ 

Source
pub fn clip_grad_value_(graph: &mut Graph, node_ids: &[NodeId], max_val: f32)
Expand description

Clamps every gradient element to the range [-max_val, max_val] in-place.

Nodes without gradients are silently skipped. If max_val is not positive or node_ids is empty, no clamping is performed.