pub struct OnlineGradientDescent { /* private fields */ }Expand description
Online Gradient Descent for convex losses.
The learning rate schedule follows η_t = η_0 / √(t + 1) when lr_decay > 0,
otherwise a constant η_0 is used. Optional L2 regularisation applies weight
decay at each step.
Implementations§
Source§impl OnlineGradientDescent
impl OnlineGradientDescent
Sourcepub fn new(n_features: usize, loss: OGDLoss) -> Self
pub fn new(n_features: usize, loss: OGDLoss) -> Self
Create a new OGD learner for the given loss function.
Sourcepub fn with_lr_decay(self, decay: f64) -> Self
pub fn with_lr_decay(self, decay: f64) -> Self
Enable learning rate decay. When decay > 0, η_t = η_0 / √(t + 1).
Sourcepub fn stats(&self) -> &OnlineStats
pub fn stats(&self) -> &OnlineStats
Reference to running statistics.
Trait Implementations§
Source§impl Clone for OnlineGradientDescent
impl Clone for OnlineGradientDescent
Source§fn clone(&self) -> OnlineGradientDescent
fn clone(&self) -> OnlineGradientDescent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OnlineGradientDescent
impl Debug for OnlineGradientDescent
Source§impl OnlineLearner for OnlineGradientDescent
impl OnlineLearner for OnlineGradientDescent
Source§fn update(
&mut self,
features: &[f64],
label: f64,
) -> Result<OnlineUpdateResult, OnlineError>
fn update( &mut self, features: &[f64], label: f64, ) -> Result<OnlineUpdateResult, OnlineError>
Update model on a single (features, label) pair. Returns update stats.
Auto Trait Implementations§
impl Freeze for OnlineGradientDescent
impl RefUnwindSafe for OnlineGradientDescent
impl Send for OnlineGradientDescent
impl Sync for OnlineGradientDescent
impl Unpin for OnlineGradientDescent
impl UnsafeUnpin for OnlineGradientDescent
impl UnwindSafe for OnlineGradientDescent
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more