Averaged Stochastic Gradient Descent (Polyak-Ruppert averaging).
Runs a standard SGD-with-momentum trajectory while also maintaining a
running average of the parameter values. Once the step
counter passes the warm-up threshold t0_, every step blends the
current parameter into the running average using a decaying mixing
coefficient :
Before t0_ the average simply tracks ().
The averaged weights generally yield lower-variance estimators than the instantaneous parameters, especially for convex or near-convex problems, and are typically used at inference time after training has finished.
Math
Per-parameter update (post warm-up):
References
Polyak and Juditsky, "Acceleration of stochastic approximation by averaging" (SIAM J. Control Optim., 1992).
See Also
SGD : the underlying instantaneous update.
Attributes
lr_doublemomentum_doubleweight_decay_doublealpha_doublet0_doubledouble to mirror the reference framework's API but compared against integer step counts.lambd_doublemoment_std::vector<Storage>momentum_ != 0).ax_std::vector<Storage>step_std::vector<std::int64_t>Notes
The step counter is maintained per parameter slot rather than as a single global counter so that parameters introduced into training late (or temporarily frozen) still see a clean averaging schedule.
Constructors
1Construct an ASGD optimizer.
Parameters
paramsstd::vector<std::shared_ptr<TensorImpl>>lrdouble= None1e-3).momentumdouble= None0.0).weight_decaydouble= None0.0).alphadouble= None0.75).t0double= None1e6).lambddouble= None1e-4).Virtual methods
2Methods
3Allocate per-slot state on the first observed gradient.
Materialises the velocity buffer (only when momentum_ != 0)
and the running-average buffer ax_ initialised to a copy of
the current parameter. The per-slot step counter is reset to 0.
Parameters
istd::size_tpconst std::shared_ptr<TensorImpl>&Checkpoint identifier ("asgd_v1").
Apply the ASGD update for one parameter slot.
Performs the standard SGD-with-momentum step on , then —
once the per-slot step counter has passed t0_ — updates the
running average using a schedule
attenuated by the average-side decay .
Parameters
istd::size_tparams_, moment_, ax_, step_.pstd::shared_ptr<TensorImpl>&gconst Storage&