pub struct ContinualLearningTrainer<M: Model> {
pub model: M,
pub config: ContinualLearningConfig,
pub memory: MemoryBuffer,
pub task_info: HashMap<usize, TaskInfo>,
pub current_task: Option<usize>,
pub fisher_matrices: HashMap<String, Tensor>,
pub optimal_parameters: HashMap<String, Tensor>,
pub step_counter: usize,
pub task_detector: Option<TaskDetector>,
}Expand description
Continual learning trainer
Fields§
§model: MThe model being trained
config: ContinualLearningConfigConfiguration
memory: MemoryBufferMemory buffer for experience replay
task_info: HashMap<usize, TaskInfo>Task-specific information
current_task: Option<usize>Current task ID
fisher_matrices: HashMap<String, Tensor>Fisher information matrices (for EWC)
optimal_parameters: HashMap<String, Tensor>Optimal parameters (for EWC)
step_counter: usizeTraining step counter
task_detector: Option<TaskDetector>Task detection state
Implementations§
Source§impl<M: Model<Input = Tensor, Output = Tensor>> ContinualLearningTrainer<M>
impl<M: Model<Input = Tensor, Output = Tensor>> ContinualLearningTrainer<M>
Sourcepub fn new(model: M, config: ContinualLearningConfig) -> Result<Self>
pub fn new(model: M, config: ContinualLearningConfig) -> Result<Self>
Create a new continual learning trainer
Sourcepub fn start_task(&mut self, task_id: usize) -> Result<()>
pub fn start_task(&mut self, task_id: usize) -> Result<()>
Start learning a new task
Sourcepub fn learn_batch(
&mut self,
inputs: &[Tensor],
targets: &[Tensor],
task_id: Option<usize>,
) -> Result<ContinualLearningOutput>
pub fn learn_batch( &mut self, inputs: &[Tensor], targets: &[Tensor], task_id: Option<usize>, ) -> Result<ContinualLearningOutput>
Learn from a batch of data
Sourcepub fn finalize_task(&mut self, task_id: usize) -> Result<()>
pub fn finalize_task(&mut self, task_id: usize) -> Result<()>
Finalize learning for a task
Sourcepub fn evaluate_all_tasks(&self) -> Result<HashMap<usize, TaskEvaluation>>
pub fn evaluate_all_tasks(&self) -> Result<HashMap<usize, TaskEvaluation>>
Evaluate on all tasks
Sourcepub fn get_metrics(&self) -> ContinualLearningMetrics
pub fn get_metrics(&self) -> ContinualLearningMetrics
Get continual learning metrics
Auto Trait Implementations§
impl<M> Freeze for ContinualLearningTrainer<M>where
M: Freeze,
impl<M> RefUnwindSafe for ContinualLearningTrainer<M>where
M: RefUnwindSafe,
impl<M> Send for ContinualLearningTrainer<M>
impl<M> Sync for ContinualLearningTrainer<M>
impl<M> Unpin for ContinualLearningTrainer<M>where
M: Unpin,
impl<M> UnsafeUnpin for ContinualLearningTrainer<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for ContinualLearningTrainer<M>where
M: 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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