Skip to main content

Adam

Struct Adam 

Source
pub struct Adam { /* private fields */ }
Expand description

Adam optimizer over stable Parameter handles.

Implementations§

Source§

impl Adam

Source

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.

Source

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.

Source

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.

Source

pub fn zero_grad(&self)

Discard every currently accumulated parameter gradient.

Source

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.

Source

pub const fn learning_rate(&self) -> f32

Return the learning rate used by the next step.

Source

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.

Source

pub const fn step_count(&self) -> u32

Return the number of completed logical steps.

Trait Implementations§

Source§

impl Optimizer for Adam

Source§

fn zero_grad(&self)

Discard every currently accumulated parameter gradient.
Source§

fn step(&mut self) -> Result<()>

Record one logical parameter update. Read more
Source§

fn learning_rate(&self) -> f32

Return the learning rate used by the next optimizer step.
Source§

fn set_learning_rate(&mut self, learning_rate: f32) -> Result<()>

Set the learning rate used by subsequent optimizer steps. Read more
Source§

fn step_count(&self) -> u64

Return the number of completed logical optimizer steps.
Source§

fn belongs_to(&self, runtime: &Runtime) -> bool

Return whether this optimizer can participate in work owned by runtime.
Source§

fn set_finite_gate(&mut self, flag: &Matrix) -> Result<()>

Bind a device-resident finite flag gating captured updates. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Adam

§

impl !Send for Adam

§

impl !Sync for Adam

§

impl !UnwindSafe for Adam

§

impl Forget for Adam

§

impl Freeze for Adam
where *const u8 is !null: Freeze, PhantomData<MomentParameterState>: Freeze, PhantomData<usize>: Freeze, PhantomData<AdamGroupMeta>: Freeze,

§

impl Move for Adam

§

impl Unpin for Adam
where *const u8 is !null: Unpin, Rc<RefCell<ParameterState>>: Unpin, Rc<RefCell<RuntimeState>>: Unpin, Rc<StorageInner>: Unpin, Rc<MatrixSemantic>: Unpin, Rc<()>: Unpin,

§

impl UnsafeUnpin for Adam
where *const u8 is !null: UnsafeUnpin, PhantomData<MomentParameterState>: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, PhantomData<AdamGroupMeta>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckpointOptimizer for T
where T: Optimizer + Persistence,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.