rust_ml/optim/core/state.rs
1use crate::{core::error::ModelError, model::core::base::OptimizableModel};
2
3/// OptimizerState trait defines the interface for managing the state of an optimizer.
4/// It provides methods to initialize the optimizer state and update the model weights.
5/// This trait is useful to implement custom parameter update rules, as used in different
6/// optimization algorithms, like RMSProp, Adam, etc.
7pub trait OptimizerState<Input, Output, M: OptimizableModel<Input, Output>> {
8 fn initialize(&self) {}
9 // fn update_weights(&self, params: &mut P, grads: &G);
10 fn update_weights(&mut self, model: &mut M) -> Result<(), ModelError>;
11}