pub struct MonitoredEstimator<'a, E: IncrementalSupervisedEstimator, F>where
F: FnMut(BatchStats),{
pub estimator: &'a mut E,
pub callback: F,
pub step_counter: usize,
}Expand description
A wrapper that attaches a monitoring callback to any supervised incremental model.
Fields§
§estimator: &'a mut E§callback: F§step_counter: usizeImplementations§
Source§impl<'a, E: IncrementalSupervisedEstimator, F> MonitoredEstimator<'a, E, F>where
F: FnMut(BatchStats),
impl<'a, E: IncrementalSupervisedEstimator, F> MonitoredEstimator<'a, E, F>where
F: FnMut(BatchStats),
Sourcepub fn new(estimator: &'a mut E, callback: F) -> Self
pub fn new(estimator: &'a mut E, callback: F) -> Self
Examples found in repository?
examples/batch_vs_incremental_comparison.rs (lines 30-32)
7fn main() {
8 println!("===Batch vs. Incremental Convergence Comparison ===");
9
10 let x = Array2::from_shape_vec(
11 (8, 2),
12 vec![
13 1.0, 2.0, 2.0, 1.0, 3.0, 4.0, 5.0, 2.0, 4.0, 1.0, 6.0, 3.0, 7.0, 2.0, 8.0, 5.0,
14 ],
15 )
16 .unwrap();
17 let y = array![-3.5, 1.5, -5.5, 4.5, 5.5, 3.5, 8.5, 1.5];
18
19 let schedule = LearningRateSchedule::InverseScaling {
20 initial_rate: 0.05,
21 decay: 0.01,
22 power: 0.5,
23 };
24
25 let mut model = IncrementalLinearRegression::new(schedule, 0.01);
26
27 println!("Step | Mini-Batch MSE Loss");
28 println!("--------------------------");
29
30 let mut monitored = MonitoredEstimator::new(&mut model, |stats: BatchStats| {
31 println!("{:4} | {:.6}", stats.step, stats.loss);
32 });
33
34 // Run multiple incremental epoch passes over data[cite: 1]
35 for _ in 0..10 {
36 monitored.partial_fit(&x, &y).unwrap();
37 }
38}Trait Implementations§
Source§impl<'a, E: IncrementalSupervisedEstimator, F> IncrementalSupervisedEstimator for MonitoredEstimator<'a, E, F>where
F: FnMut(BatchStats),
impl<'a, E: IncrementalSupervisedEstimator, F> IncrementalSupervisedEstimator for MonitoredEstimator<'a, E, F>where
F: FnMut(BatchStats),
Auto Trait Implementations§
impl<'a, E, F> !UnwindSafe for MonitoredEstimator<'a, E, F>
impl<'a, E, F> Freeze for MonitoredEstimator<'a, E, F>where
F: Freeze,
impl<'a, E, F> RefUnwindSafe for MonitoredEstimator<'a, E, F>where
F: RefUnwindSafe,
E: RefUnwindSafe,
impl<'a, E, F> Send for MonitoredEstimator<'a, E, F>
impl<'a, E, F> Sync for MonitoredEstimator<'a, E, F>
impl<'a, E, F> Unpin for MonitoredEstimator<'a, E, F>where
F: Unpin,
impl<'a, E, F> UnsafeUnpin for MonitoredEstimator<'a, E, F>where
F: UnsafeUnpin,
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