pub struct GradientChecker { /* private fields */ }Expand description
Gradient checker for multi-parameter functions
Implementations§
Source§impl GradientChecker
impl GradientChecker
Sourcepub fn new(config: GradCheckConfig) -> Self
pub fn new(config: GradCheckConfig) -> Self
Create a new gradient checker with the given configuration
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default configuration
Sourcepub fn check_parameter(
&mut self,
param_id: String,
forward_fn: impl Fn(&[f64]) -> f64,
x: &[f64],
analytical_grad: &[f64],
) -> GradCheckResult
pub fn check_parameter( &mut self, param_id: String, forward_fn: impl Fn(&[f64]) -> f64, x: &[f64], analytical_grad: &[f64], ) -> GradCheckResult
Check gradients for a single parameter
Sourcepub fn results(&self) -> &HashMap<String, GradCheckResult>
pub fn results(&self) -> &HashMap<String, GradCheckResult>
Get results for all checked parameters
Sourcepub fn all_passed(&self) -> bool
pub fn all_passed(&self) -> bool
Check if all parameters passed
Sourcepub fn total_errors(&self) -> usize
pub fn total_errors(&self) -> usize
Get total number of errors across all parameters
Sourcepub fn print_summary(&self)
pub fn print_summary(&self)
Print summary of all checks
Auto Trait Implementations§
impl Freeze for GradientChecker
impl RefUnwindSafe for GradientChecker
impl Send for GradientChecker
impl Sync for GradientChecker
impl Unpin for GradientChecker
impl UnwindSafe for GradientChecker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more