pub struct Lars { /* private fields */ }Expand description
Layer-wise Adaptive Rate Scaling (LARS) optimizer.
Scales the learning rate per layer using the ratio of parameter norm to gradient norm, enabling stable training with very large batch sizes.
Implementations§
Source§impl Lars
impl Lars
Sourcepub fn new(base_lr: f32) -> Result<Self, OptimError>
pub fn new(base_lr: f32) -> Result<Self, OptimError>
Creates LARS with required base learning rate.
Sourcepub fn with_momentum(self, momentum: f32) -> Result<Self, OptimError>
pub fn with_momentum(self, momentum: f32) -> Result<Self, OptimError>
Sets momentum factor in [0, 1).
Sourcepub fn with_weight_decay(self, weight_decay: f32) -> Result<Self, OptimError>
pub fn with_weight_decay(self, weight_decay: f32) -> Result<Self, OptimError>
Sets L2 weight decay factor in [0, +inf).
Sourcepub fn with_trust_coefficient(
self,
trust_coefficient: f32,
) -> Result<Self, OptimError>
pub fn with_trust_coefficient( self, trust_coefficient: f32, ) -> Result<Self, OptimError>
Sets trust coefficient for the local learning rate scaling.
Sourcepub fn clear_state(&mut self)
pub fn clear_state(&mut self)
Drops optimizer state (for example when restarting training).
Sourcepub fn learning_rate(&self) -> f32
pub fn learning_rate(&self) -> f32
Returns current learning rate.
Sourcepub fn set_learning_rate(&mut self, lr: f32) -> Result<(), OptimError>
pub fn set_learning_rate(&mut self, lr: f32) -> Result<(), OptimError>
Overrides current learning rate.
Sourcepub fn step(
&mut self,
parameter_id: u64,
weights: &mut Tensor,
grad: &Tensor,
) -> Result<(), OptimError>
pub fn step( &mut self, parameter_id: u64, weights: &mut Tensor, grad: &Tensor, ) -> Result<(), OptimError>
Applies one update to raw tensor weights.
Sourcepub fn step_graph_node(
&mut self,
graph: &mut Graph,
node: NodeId,
) -> Result<(), OptimError>
pub fn step_graph_node( &mut self, graph: &mut Graph, node: NodeId, ) -> Result<(), OptimError>
Applies one update to a trainable graph node by its NodeId.
Trait Implementations§
Source§impl LearningRate for Lars
impl LearningRate for Lars
Source§fn learning_rate(&self) -> f32
fn learning_rate(&self) -> f32
Returns current optimizer learning rate.
Source§fn set_learning_rate(&mut self, lr: f32) -> Result<(), OptimError>
fn set_learning_rate(&mut self, lr: f32) -> Result<(), OptimError>
Sets optimizer learning rate after validation.
Auto Trait Implementations§
impl Freeze for Lars
impl RefUnwindSafe for Lars
impl Send for Lars
impl Sync for Lars
impl Unpin for Lars
impl UnsafeUnpin for Lars
impl UnwindSafe for Lars
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