pub struct Adam<M> {
pub cfg: AdamConfig,
/* private fields */
}
Expand description
An implementation of the Adam optimizer from Adam: A Method for Stochastic Optimization
Example Usage
Constructing using default:
let mut opt: Adam<Model> = Default::default();
Changing using new
let mut opt: Adam<Model> = Adam::new(AdamConfig {
lr: 1e-2,
betas: [0.5, 0.25],
eps: 1e-6,
weight_decay: Some(WeightDecay::Decoupled(1e-2)),
});
See module level documentation at crate::optim for examples of how to actually use an optimizer.
Fields
cfg: AdamConfig
Hyperparameter configuration
Implementations
sourceimpl<M> Adam<M>
impl<M> Adam<M>
sourcepub fn new(cfg: AdamConfig) -> Self
pub fn new(cfg: AdamConfig) -> Self
Constructs using hyperparameters from cfg
.
Trait Implementations
sourceimpl<M> GradientProvider for Adam<M>
impl<M> GradientProvider for Adam<M>
sourcefn gradient<P>(&mut self, p: &P) -> Option<Box<P::Array>>where
P: HasUniqueId + HasArrayType<Dtype = f32> + HasDevice + HasArrayData,
fn gradient<P>(&mut self, p: &P) -> Option<Box<P::Array>>where
P: HasUniqueId + HasArrayType<Dtype = f32> + HasDevice + HasArrayData,
Retrieves the data associated with
p
if there is any.
This can modify self
, for instance if velocities are calculated
based on the associated data! Read moreAuto Trait Implementations
impl<M> !RefUnwindSafe for Adam<M>
impl<M> !Send for Adam<M>
impl<M> !Sync for Adam<M>
impl<M> Unpin for Adam<M>
impl<M> !UnwindSafe for Adam<M>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more