Nadam is Adam with Nesterov's look-ahead folded into the first moment — instead of stepping along the momentum you already have, you step along where it's heading.
1m = beta1 * m + (1 - beta1) * grad2v = beta2 * v + (1 - beta2) * grad²34m_hat = m / (1 - beta1^t)5v_hat = v / (1 - beta2^t)67lookahead = beta1 * m_hat + (1 - beta1) * grad / (1 - beta1^t)8param = param - learning_rate * lookahead / (sqrt(v_hat) + epsilon)
Task: write nadam_step(params, grads, m, v, learning_rate, beta1, beta2, epsilon, timestep) returning [new_params, new_m, new_v], rounded to 4 decimal places.
timestep starts at 1.Compare the first test case against the AdaGrad and AdamW problems on identical inputs. The moments come out the same as AdamW's, but the parameter moves further — the look-ahead term is weighting the current gradient more heavily than the accumulated average does.