NAdam optimiser — Adam with Nesterov momentum (Dozat, 2016).
Replaces the bias-corrected first-moment term with a Nesterov look-ahead that blends the current gradient and the running moment . The momentum coefficient decays each step, and its running product replaces the bias correction.
Math
where is momentum_decay. Let
and .
References
Dozat, "Incorporating Nesterov Momentum into Adam" (ICLR Workshop, 2016).
See Also
Adam, AdamW, RAdam.
Attributes
lr_float2e-3 (paper recommendation).beta1_ , beta2_ , eps_ , weight_ decay_floatAdam.momentum_ decay_float4e-3.m_ , v_Storage[]mu_ product_double[]Notes
mu_product_ is a per-parameter double, not a Storage,
because it is a single scalar accumulator rather than a tensor. It is
held at F32 precision (F64 for an F64 parameter) — the precision it is
checkpointed at, which is also the reference framework's — so a
restored optimizer continues bit-identically. is the parameter's
own update count.
Weight decay (if non-zero) is added to in the standard L2 form
— there is no published "decoupled NAdam".
Constructors
1Construct a NAdam optimiser bound to params.
Parameters
paramsvector of TensorImpl shared pointerslrfloat= None2e-3.beta1, beta2float= None0.9 / 0.999.epsfloat= None1e-8.weight_ decayfloat= None0.momentum_ decayfloat= None4e-3.Static methods
1check_hyperparams
void check_hyperparams(double lr, double beta1, double beta2, double eps, double weight_decay, double momentum_decay)Check NAdam's hyper-parameters — the reference framework's constructor checks, run by the constructor and set_hyperparams.
Raises
InvalidArgumentlr, eps, weight_decay or momentum_decay is negative or NaN, or a beta lies outside [0, 1).Virtual methods
2Methods
5Allocate zero-initialised and buffers; initialise mu_product_[i] to 1.0.
set_hyperparams
void set_hyperparams(double lr, double beta1, double beta2, double eps, double weight_decay)Replace the hyper-parameters between steps; nothing is applied when check_hyperparams rejects them. momentum_decay keeps its constructed value.
Schema identifier for state_dict serialisation.
Returns
str"nadam_v1".
Compute per-step and , advance mu_product_, then apply the two-term Nesterov update.
Parameters
isize_tm_ / v_ / mu_product_.pTensorImpl shared pointergStorage