pub struct NeuralTrainer<F: Float + ScalarOperand> { /* private fields */ }
Expand description
Neural network trainer that combines optimization with training loops
Implementations§
Source§impl<F> NeuralTrainer<F>
impl<F> NeuralTrainer<F>
Sourcepub fn new(optimizer: NeuralOptimizer<F>) -> Self
pub fn new(optimizer: NeuralOptimizer<F>) -> Self
Create a new neural trainer
Sourcepub fn with_early_stopping(self, patience: usize) -> Self
pub fn with_early_stopping(self, patience: usize) -> Self
Set early stopping patience
Sourcepub fn train_epoch<LossFn, GradFn>(
&mut self,
params: &mut NeuralParameters<F>,
loss_fn: &mut LossFn,
grad_fn: &mut GradFn,
) -> Result<F, OptimizeError>where
LossFn: FnMut(&NeuralParameters<F>) -> F,
GradFn: FnMut(&NeuralParameters<F>) -> Vec<Array1<F>>,
pub fn train_epoch<LossFn, GradFn>(
&mut self,
params: &mut NeuralParameters<F>,
loss_fn: &mut LossFn,
grad_fn: &mut GradFn,
) -> Result<F, OptimizeError>where
LossFn: FnMut(&NeuralParameters<F>) -> F,
GradFn: FnMut(&NeuralParameters<F>) -> Vec<Array1<F>>,
Train for one epoch
Sourcepub fn should_stop_early(&self) -> bool
pub fn should_stop_early(&self) -> bool
Check if training should stop early
Sourcepub fn loss_history(&self) -> &[F]
pub fn loss_history(&self) -> &[F]
Get loss history
Sourcepub fn learning_rate(&self) -> f64
pub fn learning_rate(&self) -> f64
Get current learning rate
Sourcepub fn set_learning_rate(&mut self, lr: f64)
pub fn set_learning_rate(&mut self, lr: f64)
Set learning rate
Auto Trait Implementations§
impl<F> Freeze for NeuralTrainer<F>where
F: Freeze,
impl<F> RefUnwindSafe for NeuralTrainer<F>where
F: RefUnwindSafe,
impl<F> Send for NeuralTrainer<F>where
F: Send,
impl<F> Sync for NeuralTrainer<F>where
F: Sync,
impl<F> Unpin for NeuralTrainer<F>where
F: Unpin,
impl<F> UnwindSafe for NeuralTrainer<F>where
F: UnwindSafe + RefUnwindSafe,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.