Struct zyx_optim::Adam

source ·
pub struct Adam<B: Backend> {
    pub learning_rate: f32,
    pub betas: (f32, f32),
    pub eps: f32,
    pub weight_decay: f32,
    pub amsgrad: bool,
    pub maximize: bool,
    pub m: Vec<Tensor<B>>,
    pub v: Vec<Tensor<B>>,
    pub vm: Vec<Tensor<B>>,
    pub t: usize,
}
Expand description

§Adaptive momentum estimation optimizer

Fields§

§learning_rate: f32

learning rate (default: 1e-3)

§betas: (f32, f32)

coefficients used for computing running averages of gradient and its square (default: (0.9, 0.999))

§eps: f32

term added to the denominator to improve numerical stability (default: 1e-8)

§weight_decay: f32

weight decay (L2 penalty) (default: 0)

§amsgrad: bool

whether to use the AMSGrad variant of this algorithm from the paper On the Convergence of Adam and Beyond (default: false)

§maximize: bool

maximize the objective with respect to the params, instead of minimizing (default: false)

§m: Vec<Tensor<B>>

m

§v: Vec<Tensor<B>>

v

§vm: Vec<Tensor<B>>

vm

§t: usize

t

Implementations§

source§

impl<B: Backend> Adam<B>

source

pub fn update<'a>( &mut self, parameters: impl IntoIterator<Item = &'a mut Tensor<B>>, gradients: impl IntoIterator<Item = Option<Tensor<B>>> )
where B: 'a,

Updates parameters with gradients. Number of parameters must be the same as number of gradients. Gradients can be None, those are simply skipped.

Trait Implementations§

source§

impl<B: Backend> Default for Adam<B>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<B> Freeze for Adam<B>

§

impl<B> RefUnwindSafe for Adam<B>
where B: RefUnwindSafe,

§

impl<B> Send for Adam<B>
where B: Send,

§

impl<B> Sync for Adam<B>
where B: Sync,

§

impl<B> Unpin for Adam<B>
where B: Unpin,

§

impl<B> UnwindSafe for Adam<B>
where B: UnwindSafe,

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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.