pub struct Adam { /* private fields */ }Expand description
Adam optimizer over stable Parameter handles.
Implementations§
Source§impl Adam
impl Adam
Sourcepub fn new(
parameters: impl IntoIterator<Item = Parameter>,
learning_rate: f32,
) -> Result<Self>
pub fn new( parameters: impl IntoIterator<Item = Parameter>, learning_rate: f32, ) -> Result<Self>
Bind Adam to a nonempty parameter set using standard OA defaults.
§Errors
Returns an error for invalid ownership, duplicate parameters, or moment allocation failure.
Sourcepub fn new_with_hyperparameters(
parameters: impl IntoIterator<Item = Parameter>,
learning_rate: f32,
beta1: f32,
beta2: f32,
epsilon: f32,
) -> Result<Self>
pub fn new_with_hyperparameters( parameters: impl IntoIterator<Item = Parameter>, learning_rate: f32, beta1: f32, beta2: f32, epsilon: f32, ) -> Result<Self>
Bind Adam with explicit scalar hyperparameters.
§Errors
Returns an error for non-finite or out-of-range scalars, an empty or duplicate parameter set, mixed-runtime ownership, or moment allocation.
Sourcepub fn new_with_groups(
groups: Vec<ParameterGroup>,
learning_rate: f32,
beta1: f32,
beta2: f32,
epsilon: f32,
) -> Result<Self>
pub fn new_with_groups( groups: Vec<ParameterGroup>, learning_rate: f32, beta1: f32, beta2: f32, epsilon: f32, ) -> Result<Self>
Bind Adam over named parameter groups following the AdamW contract.
Adam applies no weight decay, so group decay replacements are
vacuously satisfied; lr_scale and frozen carry the differential
treatment.
§Errors
Returns the construction errors of the uniform constructor plus overlapping membership, empty groups, and invalid group scales.
Sourcepub fn step(&mut self) -> Result<()>
pub fn step(&mut self) -> Result<()>
Record one Adam update for every parameter carrying a gradient.
§Errors
Returns an error when the step counter is exhausted, a parameter contract changed, or runtime recording fails.
Sourcepub const fn learning_rate(&self) -> f32
pub const fn learning_rate(&self) -> f32
Return the learning rate used by the next step.
Sourcepub fn set_learning_rate(&mut self, learning_rate: f32) -> Result<()>
pub fn set_learning_rate(&mut self, learning_rate: f32) -> Result<()>
Set the learning rate used by subsequent steps.
§Errors
Returns an error when the value is not finite and non-negative.
Sourcepub const fn step_count(&self) -> u32
pub const fn step_count(&self) -> u32
Return the number of completed logical steps.
Trait Implementations§
Source§impl Optimizer for Adam
impl Optimizer for Adam
Source§fn learning_rate(&self) -> f32
fn learning_rate(&self) -> f32
Source§fn set_learning_rate(&mut self, learning_rate: f32) -> Result<()>
fn set_learning_rate(&mut self, learning_rate: f32) -> Result<()>
Source§fn step_count(&self) -> u64
fn step_count(&self) -> u64
Source§fn belongs_to(&self, runtime: &Runtime) -> bool
fn belongs_to(&self, runtime: &Runtime) -> bool
runtime.