pub struct SGD {
pub learning_rate: f32,
pub momentum: f32,
pub weight_decay: f32,
pub dampening: f32,
pub nesterov: bool,
pub maximize: bool,
pub bias: Vec<Tensor>,
}Expand description
§Stochastic gradient descent optimizer
Fields§
§learning_rate: f32learning rate (default: 0.001)
momentum: f32momentum factor (default: 0.0)
weight_decay: f32weight decay (L2 penalty) (default: 0.0)
dampening: f32dampening for momentum (default: 0.0)
nesterov: boolenables Nesterov momentum (default: false)
maximize: boolmaximize the objective with respect to the params, instead of minimizing (default: false)
bias: Vec<Tensor>stores momentum, starts empty and will be initialized on demand
Implementations§
Source§impl SGD
impl SGD
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 SGD
impl<'a> IntoIterator for &'a SGD
Source§impl<'a> IntoIterator for &'a mut SGD
impl<'a> IntoIterator for &'a mut SGD
Source§impl Module for SGD
impl Module for SGD
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 SGD
impl RefUnwindSafe for SGD
impl Send for SGD
impl Sync for SGD
impl Unpin for SGD
impl UnsafeUnpin for SGD
impl UnwindSafe for SGD
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