Nesterov Accelerated Gradient (NAG) is an optimization algorithm used in deep learning. It is an extension of SGD with momentum. NAG calculates the gradient not only at the current position but also a step ahead in the direction of the momentum. This allows it to anticipate the momentum's effect and make more accurate updates. NAG effectively "looks ahead" before updating the parameters, which improves convergence speed and helps avoid overshooting the optimal solution. By incorporating this lookahead approach, NAG enhances the momentum-based optimization and leads to faster convergence and better performance of neural networks.
Formula:
$$v_{t} = \beta \cdot v_{t-1} + (1 - \beta) \cdot \nabla J(\theta - \beta \cdot v_{t-1}) $$
$$\theta = \theta - \alpha \cdot v_{t}$$
Keras code Example:
SGD:
tf.keras.optimizers.SGD(learning_rate=0.01)
SGD with momentum:
tf.keras.optimizers.SGD(learning_rate=0.01, momentum=0.9)
NAG:
tf.keras.optimizers.SGD(learning_rate=0.01, momentum=0.9, nesterov=True)