pub struct Trainer { /* private fields */ }
Expand description
Model trainer for neural networks.
Implementations§
Source§impl Trainer
impl Trainer
Sourcepub fn new(
model: Sequential,
optimizer: Box<dyn Optimizer>,
lossfn: Box<dyn Loss>,
) -> Self
pub fn new( model: Sequential, optimizer: Box<dyn Optimizer>, lossfn: Box<dyn Loss>, ) -> Self
Create a new trainer.
Sourcepub fn add_callback(&mut self, callback: Box<dyn TrainingCallback>)
pub fn add_callback(&mut self, callback: Box<dyn TrainingCallback>)
Add a callback to the trainer.
Sourcepub fn train(
&mut self,
train_loader: &mut DataLoader,
numepochs: usize,
val_loader: Option<&mut DataLoader>,
) -> CoreResult<()>
pub fn train( &mut self, train_loader: &mut DataLoader, numepochs: usize, val_loader: Option<&mut DataLoader>, ) -> CoreResult<()>
Train the model.
Sourcepub const fn train_metrics(&self) -> &Metrics
pub const fn train_metrics(&self) -> &Metrics
Get training metrics.
Sourcepub fn val_metrics(&self) -> Option<&Metrics>
pub fn val_metrics(&self) -> Option<&Metrics>
Get validation metrics.
Auto Trait Implementations§
impl Freeze for Trainer
impl !RefUnwindSafe for Trainer
impl !Send for Trainer
impl !Sync for Trainer
impl Unpin for Trainer
impl !UnwindSafe for Trainer
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