pub struct Adam {
pub learning_rate: f32,
pub betas: (f32, f32),
pub eps: f32,
pub weight_decay: f32,
pub amsgrad: bool,
pub m: Vec<Tensor>,
pub v: Vec<Tensor>,
pub vm: Vec<Tensor>,
pub t: usize,
}Expand description
§Adaptive momentum estimation optimizer
Fields§
§learning_rate: f32learning rate (default: 1e-3)
betas: (f32, f32)coefficients used for computing running averages of gradient and its square (default: (0.9, 0.999))
eps: f32term added to the denominator to improve numerical stability (default: 1e-8)
weight_decay: f32weight decay (L2 penalty) (default: 0)
amsgrad: boolwhether to use the AMSGrad variant of this algorithm from the paper On the Convergence of Adam and Beyond (default: false)
m: Vec<Tensor>m
v: Vec<Tensor>v
vm: Vec<Tensor>vm
t: usizet
Implementations§
Source§impl Adam
impl Adam
Sourcepub fn update<'a>(
&mut self,
parameters: impl IntoIterator<Item = &'a mut Tensor>,
gradients: impl IntoIterator<Item = Option<Tensor>>,
)
pub fn update<'a>( &mut self, parameters: impl IntoIterator<Item = &'a mut Tensor>, gradients: impl IntoIterator<Item = Option<Tensor>>, )
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<'a> IntoIterator for &'a Adam
impl<'a> IntoIterator for &'a Adam
Source§impl<'a> IntoIterator for &'a mut Adam
impl<'a> IntoIterator for &'a mut Adam
Source§impl Module for Adam
impl Module for Adam
Source§fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut Tensor>
fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut Tensor>
Iterate over all tensors mutably
Source§fn iter_tensors<'a>(&'a self) -> impl Iterator<Item = (String, &'a Tensor)>
fn iter_tensors<'a>(&'a self) -> impl Iterator<Item = (String, &'a Tensor)>
Iterate over tensors without consuming the module
Source§fn iter_tensors_mut<'a>(
&'a mut self,
) -> impl Iterator<Item = (String, &'a mut Tensor)>
fn iter_tensors_mut<'a>( &'a mut self, ) -> impl Iterator<Item = (String, &'a mut Tensor)>
From tensors
Auto Trait Implementations§
impl Freeze for Adam
impl RefUnwindSafe for Adam
impl Send for Adam
impl Sync for Adam
impl Unpin for Adam
impl UnsafeUnpin for Adam
impl UnwindSafe for Adam
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