pub struct Sgd<M, E: Dtype, D: Storage<E>> {
pub cfg: SgdConfig,
/* private fields */
}
Expand description
Implementation of Stochastic Gradient Descent. Based on pytorch’s implementation
Nesterov Momentum is implemented as described in On the importance of initialization and momentum in deep learning.
Weight decay is implemented as described in Decoupled Weight Decay Regularization Both L2 weight_decay and decoupled weight_decay are available.
Example Usage
let mut opt: Sgd<Model, f32, Cpu> = Sgd::new(&model, SgdConfig {
lr: 1e-3,
momentum: Some(Momentum::Classic(0.5)),
weight_decay: Some(WeightDecay::L2(0.01)),
});
See module level documentation at crate::optim for examples of how to actually use an optimizer.
Fields§
§cfg: SgdConfig
Hyperparameter configuration
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<M, E, D> RefUnwindSafe for Sgd<M, E, D>where M: RefUnwindSafe, <D as Storage<E>>::Vec: RefUnwindSafe,
impl<M, E, D> !Send for Sgd<M, E, D>
impl<M, E, D> !Sync for Sgd<M, E, D>
impl<M, E, D> Unpin for Sgd<M, E, D>
impl<M, E, D> UnwindSafe for Sgd<M, E, D>where M: RefUnwindSafe, <D as Storage<E>>::Vec: RefUnwindSafe,
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