pub struct Learner<LC: LearningComponentsTypes> { /* private fields */ }Expand description
Learner struct encapsulating all components necessary to train a Neural Network model.
Implementations§
Source§impl<B, LR, M, O> Learner<LearningComponentsMarker<B, LR, M, O>>where
B: AutodiffBackend,
LR: LrScheduler + 'static,
M: TrainStep + AutodiffModule<B> + Display + 'static,
M::InnerModule: InferenceStep,
O: Optimizer<M, B> + 'static,
impl<B, LR, M, O> Learner<LearningComponentsMarker<B, LR, M, O>>where
B: AutodiffBackend,
LR: LrScheduler + 'static,
M: TrainStep + AutodiffModule<B> + Display + 'static,
M::InnerModule: InferenceStep,
O: Optimizer<M, B> + 'static,
Source§impl<LC: LearningComponentsTypes> Learner<LC>
impl<LC: LearningComponentsTypes> Learner<LC>
Sourcepub fn fork(&mut self, device: &<TrainingBackend<LC> as Backend>::Device)
pub fn fork(&mut self, device: &<TrainingBackend<LC> as Backend>::Device)
Fork the learner’s model to the given device.
Sourcepub fn model(&self) -> LC::TrainingModel
pub fn model(&self) -> LC::TrainingModel
Returns the current model.
Sourcepub fn lr_current(&self) -> f64
pub fn lr_current(&self) -> f64
Returns the current learning rate.
Sourcepub fn train_step(
&self,
item: <<LC as LearningComponentsTypes>::TrainingModel as TrainStep>::Input,
) -> TrainOutput<<<LC as LearningComponentsTypes>::TrainingModel as TrainStep>::Output>
pub fn train_step( &self, item: <<LC as LearningComponentsTypes>::TrainingModel as TrainStep>::Input, ) -> TrainOutput<<<LC as LearningComponentsTypes>::TrainingModel as TrainStep>::Output>
Sourcepub fn optimizer_step(&mut self, grads: GradientsParams)
pub fn optimizer_step(&mut self, grads: GradientsParams)
Optimize the current module with the provided gradients and learning rate.
§Arguments
optim: Optimizer used for learning.lr: The learning rate used for this step.grads: The gradients of each parameter in the current model.
Sourcepub fn optimizer_step_multi(&mut self, grads: MultiGradientsParams)
pub fn optimizer_step_multi(&mut self, grads: MultiGradientsParams)
Optimize the current module with the provided gradients and learning rate.
§Arguments
optim: Optimizer used for learning.lr: The learning rate used for this step.grads: Multiple gradients associated to each parameter in the current model.
Sourcepub fn load_model(&mut self, record: LearnerModelRecord<LC>)
pub fn load_model(&mut self, record: LearnerModelRecord<LC>)
Load the module state from a record.
Sourcepub fn load_optim(&mut self, record: LearnerOptimizerRecord<LC>)
pub fn load_optim(&mut self, record: LearnerOptimizerRecord<LC>)
Load the state of the learner’s optimizer as a record.
Sourcepub fn load_scheduler(&mut self, record: LearnerSchedulerRecord<LC>)
pub fn load_scheduler(&mut self, record: LearnerSchedulerRecord<LC>)
Load the state of the learner’s scheduler as a record.
Trait Implementations§
Auto Trait Implementations§
impl<LC> Freeze for Learner<LC>where
<LC as LearningComponentsTypes>::TrainingModel: Freeze,
<LC as LearningComponentsTypes>::Optimizer: Freeze,
<LC as LearningComponentsTypes>::LrScheduler: Freeze,
impl<LC> RefUnwindSafe for Learner<LC>where
<LC as LearningComponentsTypes>::TrainingModel: RefUnwindSafe,
<LC as LearningComponentsTypes>::Optimizer: RefUnwindSafe,
<LC as LearningComponentsTypes>::LrScheduler: RefUnwindSafe,
impl<LC> Send for Learner<LC>
impl<LC> Sync for Learner<LC>where
<LC as LearningComponentsTypes>::TrainingModel: Sync,
<LC as LearningComponentsTypes>::Optimizer: Sync,
impl<LC> Unpin for Learner<LC>where
<LC as LearningComponentsTypes>::TrainingModel: Unpin,
<LC as LearningComponentsTypes>::Optimizer: Unpin,
<LC as LearningComponentsTypes>::LrScheduler: Unpin,
impl<LC> UnwindSafe for Learner<LC>where
<LC as LearningComponentsTypes>::TrainingModel: UnwindSafe,
<LC as LearningComponentsTypes>::Optimizer: UnwindSafe,
<LC as LearningComponentsTypes>::LrScheduler: 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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