Momentum in Optimization
Momentum is an optimization technique used in the training of deep learning models to accelerate the gradient descent algorithm. It achieves this by averaging past gradients, which helps the optimization process to efficiently navigate through small flat regions and continue moving downhill.
Overview of Momentum
The primary goal of momentum is to improve the convergence speed of gradient descent by incorporating a memory of past gradients. This memory allows the algorithm to maintain a consistent direction in the optimization path, even when faced with noisy gradient estimates. By averaging these past gradients, momentum strengthens the downhill component of the gradient and cancels out the non-downhill components, which are often random.
The Momentum Equation
The momentum equation updates the parameters by taking a weighted average of the current gradient and the previous update. This approach smooths the optimization path and helps in overcoming small flat regions in the loss surface. The equation can be expressed as:
[ v_t = \gamma v_{t-1} + \eta \nabla \theta_t ] [ \theta_{t+1} = \theta_t - v_t ]
where ( v_t ) is the velocity (or momentum) term, ( \gamma ) is the momentum coefficient, ( \eta ) is the learning rate, and ( \nabla \theta_t ) is the gradient of the loss with respect to the parameters at time ( t ).
Constant Loss Contours and Gradient Descent
In the context of gradient descent, constant loss contours are concentric circles that represent equal loss values. The negative gradient direction is radially inward, leading to a decrease in loss. Momentum aids in moving efficiently along these contours by averaging past gradients, which helps in maintaining a consistent direction and speed.
Nesterov Accelerated Gradients
Nesterov accelerated gradients (NAG) is an enhancement of the momentum-based gradient descent. It estimates the destination point of the update and computes the gradient at that point, rather than at the current position. This foresight helps in mitigating the overshooting phenomenon that can occur near the minimum of the loss surface.
Visualization of Momentum
The following figure illustrates the concept of momentum in the context of noisy stochastic gradient estimates:
Figure 9.8 Momentum. Noisy stochastic gradient estimates at different points on the loss surface (thick solid arrows) are not aligned in direction, but they all have a significant downhill component (thin solid arrows). The non-downhill components thin dashed arrows) point in random directions. Hence, averaging tends to strengthen the downhill component and cancel out the non-downhill components.
In real-life high-dimensional loss surfaces, the analogy of a ravine is quite fitting. The loss surface is not smooth but rather rugged, similar to the walls of the Grand Canyon. Gradient estimates, often computed over a minibatch, are noisy and not aligned in one direction. However, they generally have a significant downhill component, while the non-downhill components are random. By averaging these gradients, the downhill components are reinforced, and the non-downhill components are weakened, allowing for more efficient optimization.