pub enum Optimizer {
Sgd(Sgd),
AdaGrad(AdaGrad),
}Expand description
Concrete optimizer enum wrapping all supported optimizers.
Variants§
Sgd(Sgd)
Stochastic gradient descent with optional L2 regularization.
AdaGrad(AdaGrad)
AdaGrad with per-parameter squared gradient accumulation.
Implementations§
Source§impl Optimizer
impl Optimizer
Sourcepub fn sgd(feature_count: usize, config: SgdConfig) -> Result<Self, RillError>
pub fn sgd(feature_count: usize, config: SgdConfig) -> Result<Self, RillError>
Create an SGD optimizer for feature_count features (plus intercept).
Sourcepub fn adagrad(
feature_count: usize,
config: AdaGradConfig,
) -> Result<Self, RillError>
pub fn adagrad( feature_count: usize, config: AdaGradConfig, ) -> Result<Self, RillError>
Create an AdaGrad optimizer for feature_count features (plus intercept).
Sourcepub fn param_count(&self) -> usize
pub fn param_count(&self) -> usize
The number of parameters this optimizer manages (features + intercept).
Sourcepub fn samples_seen(&self) -> u64
pub fn samples_seen(&self) -> u64
Number of samples the optimizer has processed.
Sourcepub fn step(
&mut self,
weights: &mut [f64],
intercept: &mut f64,
grad_weights: &[f64],
grad_intercept: f64,
) -> Result<(), RillError>
pub fn step( &mut self, weights: &mut [f64], intercept: &mut f64, grad_weights: &[f64], grad_intercept: f64, ) -> Result<(), RillError>
Apply a gradient step to weights (length feature_count) and
intercept (single value). The gradient vector passed in must have
the same length as weights; the intercept gradient is passed
separately.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Optimizer
impl RefUnwindSafe for Optimizer
impl Send for Optimizer
impl Sync for Optimizer
impl Unpin for Optimizer
impl UnsafeUnpin for Optimizer
impl UnwindSafe for Optimizer
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