entrenar/train/curriculum/scheduler.rs
1//! Curriculum scheduler trait
2
3/// Trait for curriculum learning schedulers
4///
5/// Determines training difficulty/tier based on training progress.
6pub trait CurriculumScheduler: Send {
7 /// Get the current difficulty level (0.0 = easiest, 1.0 = hardest)
8 fn difficulty(&self) -> f32;
9
10 /// Get the current tier (for tiered training like CITL)
11 fn tier(&self) -> usize;
12
13 /// Advance the curriculum based on training progress
14 fn step(&mut self, epoch: usize, accuracy: f32);
15
16 /// Reset the curriculum to initial state
17 fn reset(&mut self);
18
19 /// Get sample weight for a given difficulty score
20 ///
21 /// Returns weight multiplier for loss (1.0 = normal weight)
22 fn sample_weight(&self, sample_difficulty: f32) -> f32 {
23 1.0 - (sample_difficulty - self.difficulty()).abs().min(1.0) * 0.5
24 }
25
26 /// Check if sample should be included at current difficulty
27 fn include_sample(&self, sample_difficulty: f32) -> bool {
28 sample_difficulty <= self.difficulty()
29 }
30
31 /// Name of the curriculum scheduler
32 fn name(&self) -> &str;
33}