pub struct ASGD { /* private fields */ }Expand description
Averaged Stochastic Gradient Descent (ASGD) optimizer
This implements the Averaged SGD algorithm which maintains a running average of parameters during training. It can achieve better convergence properties than standard SGD in certain scenarios.
Implementations§
Source§impl ASGD
impl ASGD
Sourcepub fn new(
params: Vec<Arc<RwLock<Tensor>>>,
lr: Option<f32>,
alpha: Option<f32>,
t0: Option<f32>,
lambd: Option<f32>,
weight_decay: Option<f32>,
) -> Self
pub fn new( params: Vec<Arc<RwLock<Tensor>>>, lr: Option<f32>, alpha: Option<f32>, t0: Option<f32>, lambd: Option<f32>, weight_decay: Option<f32>, ) -> Self
Create a new ASGD optimizer
§Arguments
params- Parameters to optimizelr- Learning rate (default: 1e-2)alpha- Power for computing average (default: 0.75)t0- Point at which to start averaging (default: 1e6)lambd- Decay term (default: 1e-4)weight_decay- Weight decay (L2 penalty) (default: 0.0)
Trait Implementations§
Source§impl Optimizer for ASGD
impl Optimizer for ASGD
Source§fn step(&mut self) -> OptimizerResult<()>
fn step(&mut self) -> OptimizerResult<()>
Perform a single optimization step
Source§fn add_param_group(
&mut self,
params: Vec<Arc<RwLock<Tensor>>>,
options: HashMap<String, f32>,
)
fn add_param_group( &mut self, params: Vec<Arc<RwLock<Tensor>>>, options: HashMap<String, f32>, )
Add a parameter group
Source§fn parameters(&self) -> Vec<Arc<RwLock<Tensor>>>
fn parameters(&self) -> Vec<Arc<RwLock<Tensor>>>
Get the parameter tensors managed by this optimizer. Read more
Source§fn state_dict(&self) -> OptimizerResult<OptimizerState>
fn state_dict(&self) -> OptimizerResult<OptimizerState>
Get state dict for serialization
Source§fn load_state_dict(&mut self, state: OptimizerState) -> OptimizerResult<()>
fn load_state_dict(&mut self, state: OptimizerState) -> OptimizerResult<()>
Load state dict
Auto Trait Implementations§
impl !RefUnwindSafe for ASGD
impl !UnwindSafe for ASGD
impl Freeze for ASGD
impl Send for ASGD
impl Sync for ASGD
impl Unpin for ASGD
impl UnsafeUnpin for ASGD
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<O> OptimizerExt for Owhere
O: Optimizer,
impl<O> OptimizerExt for Owhere
O: Optimizer,
Source§fn distributed(
self,
config: DistributedConfig,
) -> OptimizerResult<DistributedOptimizer<Self>>
fn distributed( self, config: DistributedConfig, ) -> OptimizerResult<DistributedOptimizer<Self>>
Wrap this optimizer with distributed functionality