pub struct GradientChecker<T: FloatBounds + ScalarOperand + ToPrimitive> { /* private fields */ }Expand description
Gradient checker for neural networks
Implementations§
Source§impl<T: FloatBounds + ScalarOperand + ToPrimitive> GradientChecker<T>
impl<T: FloatBounds + ScalarOperand + ToPrimitive> GradientChecker<T>
Sourcepub fn new(config: GradientCheckConfig<T>) -> Self
pub fn new(config: GradientCheckConfig<T>) -> Self
Create a new gradient checker
Sourcepub fn check_network_gradients(
&self,
network: &mut SimpleMLP<T>,
inputs: &Array2<T>,
targets: &Array2<T>,
loss_fn: &dyn LossFunction<T>,
) -> Result<GradientCheckResults<T>, SklearsError>
pub fn check_network_gradients( &self, network: &mut SimpleMLP<T>, inputs: &Array2<T>, targets: &Array2<T>, loss_fn: &dyn LossFunction<T>, ) -> Result<GradientCheckResults<T>, SklearsError>
Check gradients for a neural network
Sourcepub fn check_layer_gradients(
&self,
layer: &mut DenseLayer<T>,
inputs: &Array2<T>,
output_gradients: &Array2<T>,
) -> Result<GradientCheckResults<T>, SklearsError>
pub fn check_layer_gradients( &self, layer: &mut DenseLayer<T>, inputs: &Array2<T>, output_gradients: &Array2<T>, ) -> Result<GradientCheckResults<T>, SklearsError>
Check gradients for a single layer
Source§impl<T: FloatBounds + ScalarOperand + ToPrimitive> GradientChecker<T>
Utility functions for gradient checking
impl<T: FloatBounds + ScalarOperand + ToPrimitive> GradientChecker<T>
Utility functions for gradient checking
Sourcepub fn gradients_are_equal(&self, analytical: T, numerical: T) -> bool
pub fn gradients_are_equal(&self, analytical: T, numerical: T) -> bool
Check if gradients are approximately equal
Sourcepub fn compute_relative_error(&self, analytical: T, numerical: T) -> T
pub fn compute_relative_error(&self, analytical: T, numerical: T) -> T
Compute relative error between two gradients
Sourcepub fn generate_report(&self, results: &GradientCheckResults<T>) -> String
pub fn generate_report(&self, results: &GradientCheckResults<T>) -> String
Generate a summary report of gradient checking results
Trait Implementations§
Source§impl<T: Debug + FloatBounds + ScalarOperand + ToPrimitive> Debug for GradientChecker<T>
impl<T: Debug + FloatBounds + ScalarOperand + ToPrimitive> Debug for GradientChecker<T>
Auto Trait Implementations§
impl<T> Freeze for GradientChecker<T>where
T: Freeze,
impl<T> RefUnwindSafe for GradientChecker<T>where
T: RefUnwindSafe,
impl<T> Send for GradientChecker<T>
impl<T> Sync for GradientChecker<T>
impl<T> Unpin for GradientChecker<T>where
T: Unpin,
impl<T> UnwindSafe for GradientChecker<T>where
T: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more