pub struct Sgd { /* private fields */ }Expand description
SGD optimizer with optional L2 regularization.
The update rule for each weight w_i is:
w_i -= lr * (grad_i + l2 * w_i)The intercept is not regularized.
Implementations§
Source§impl Sgd
impl Sgd
Sourcepub fn new(feature_count: usize, config: SgdConfig) -> Result<Self, RillError>
pub fn new(feature_count: usize, config: SgdConfig) -> Result<Self, RillError>
Create a new SGD optimizer.
Sourcepub const fn learning_rate(&self) -> f64
pub const fn learning_rate(&self) -> f64
The configured learning rate.
Sourcepub const fn param_count(&self) -> usize
pub const fn param_count(&self) -> usize
Number of parameters (features + intercept).
Sourcepub const fn samples_seen(&self) -> u64
pub const fn samples_seen(&self) -> u64
Number of samples processed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sgd
impl RefUnwindSafe for Sgd
impl Send for Sgd
impl Sync for Sgd
impl Unpin for Sgd
impl UnsafeUnpin for Sgd
impl UnwindSafe for Sgd
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