pub struct Trainer { /* private fields */ }Expand description
High-level trainer that wraps optimizer + loss + callbacks configuration.
Implementations§
Source§impl Trainer
impl Trainer
Sourcepub fn new(config: TrainerConfig) -> Self
pub fn new(config: TrainerConfig) -> Self
Create a new trainer with the given configuration.
Sourcepub fn add_callback(&mut self, cb: Box<dyn TrainingCallback>) -> &mut Self
pub fn add_callback(&mut self, cb: Box<dyn TrainingCallback>) -> &mut Self
Add a callback (EarlyStopping, BestModelCheckpoint, etc.).
Sourcepub fn fit(
&mut self,
model: &mut SequentialModel,
graph: &mut Graph,
inputs: &Tensor,
targets: &Tensor,
) -> Result<TrainResult, ModelError>
pub fn fit( &mut self, model: &mut SequentialModel, graph: &mut Graph, inputs: &Tensor, targets: &Tensor, ) -> Result<TrainResult, ModelError>
Train the model on the given data.
inputs and targets are combined into a SupervisedDataset. For each
epoch the method runs a full pass over mini-batches, computes the loss,
back-propagates, and steps the optimizer. Callbacks are invoked after
every epoch and may request early stopping.
Auto Trait Implementations§
impl Freeze for Trainer
impl !RefUnwindSafe for Trainer
impl !Send for Trainer
impl !Sync for Trainer
impl Unpin for Trainer
impl UnsafeUnpin 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