concision_data/trainer/
impl_trainer.rs

1/*
2    Appellation: impl_trainer <module>
3    Created At: 2025.11.28:13:12:11
4    Contrib: @FL03
5*/
6use super::Trainer;
7use crate::dataset::DatasetBase;
8use crate::{IntoDataset, Records};
9use concision_core::Model;
10
11impl<'a, M, T, R> Trainer<'a, M, T, R>
12where
13    M: Model<T>,
14    R: Records,
15{
16    pub fn new(model: &'a mut M, dataset: R) -> Self
17    where
18        R: IntoDataset<R::Inputs, R::Targets>,
19        T: Default,
20    {
21        Self {
22            dataset: dataset.into_dataset(),
23            model,
24            loss: T::default(),
25        }
26    }
27    /// returns an immutable reference to the total loss
28    pub const fn loss(&self) -> &T {
29        &self.loss
30    }
31    /// returns a mutable reference to the total loss
32    pub fn loss_mut(&mut self) -> &mut T {
33        &mut self.loss
34    }
35    /// returns an immutable reference to the training session's dataset
36    pub const fn dataset(&self) -> &DatasetBase<R::Inputs, R::Targets> {
37        &self.dataset
38    }
39    /// returns a mutable reference to the training session's dataset
40    pub fn dataset_mut(&mut self) -> &mut DatasetBase<R::Inputs, R::Targets> {
41        &mut self.dataset
42    }
43
44    pub fn begin(&self) -> &Self {
45        todo!("Define a generic training loop...")
46    }
47}