pub struct AdamW { /* private fields */ }Expand description
AdamW optimizer with decoupled weight decay.
Implementations§
Source§impl AdamW
impl AdamW
Sourcepub fn new(lr: f32) -> Result<Self, OptimError>
pub fn new(lr: f32) -> Result<Self, OptimError>
Creates AdamW with required learning rate.
Sourcepub fn with_beta1(self, beta1: f32) -> Result<Self, OptimError>
pub fn with_beta1(self, beta1: f32) -> Result<Self, OptimError>
Sets beta1 factor in [0, 1).
Sourcepub fn with_beta2(self, beta2: f32) -> Result<Self, OptimError>
pub fn with_beta2(self, beta2: f32) -> Result<Self, OptimError>
Sets beta2 factor in [0, 1).
Sourcepub fn with_epsilon(self, epsilon: f32) -> Result<Self, OptimError>
pub fn with_epsilon(self, epsilon: f32) -> Result<Self, OptimError>
Sets epsilon value, must be finite and > 0.
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 decoupled weight decay factor in [0, +inf).
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 AdamW
impl LearningRate for AdamW
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 AdamW
impl RefUnwindSafe for AdamW
impl Send for AdamW
impl Sync for AdamW
impl Unpin for AdamW
impl UnsafeUnpin for AdamW
impl UnwindSafe for AdamW
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