How close can noisy gradient descent get?
Suppose we want to minimize some loss via gradient descent. At each step, we receive the true gradient plus some randomly sampled noise . We run this noisy gradient descent with a constant learning rate.
What happens? Do we converge to the true minimum of ? Or do we hover within some range of it?
Turns out we hover within some range (a sort of “cloud”) around the minimum. The size of this cloud depends on the step size, the magnitude of the noise, and the local curvature of the loss.
The 1D quadratic case
Consider a simple 1D quadratic loss function
where is the parameter to be learned, and is a constant that controls the curvature of the quadratic. The minimum is at , and the true gradient is .
Now suppose noisy gradient descent sees
where each noise term is an independently drawn random variable with and .
We can write one step of noisy gradient descent as
Letting , we can write
Note that we’ll assume (or equivalently ). If this were not the case, then learning would be unstable, with the iterate blowing up to infinity.1
Analysis of parameter iterates
The expectation of an iterate
Note that we can think of each iterate as a random variable – each depends on all the random noise terms sampled up to that point: .
Let We write the expectation of the next iterate as a simple recursion:
Thus, the expectation of iterates evolves as
If , then , so
From this, we see that the expectation of iterates goes to the minimum. However, we will see that actual iterates do not stay there – they have non-zero variance, driven by the fact that new noise is injected at every step.
The variance of an iterate
Let Then
Note that there is no cross term because the noise is independent of the iterate .
At stationarity (i.e., when we’re in the final “cloud”), the variance stops changing, so . Therefore
Now substitute :
So the stationary parameter variance is
This is the noise floor in the toy model. Smaller learning rates and lower gradient noise shrink the cloud, while smaller curvature expands it.
Analysis of loss
So far, we have described the cloud in parameter space.
At stationarity, is a random variable with
We can compute statistics of the loss, since the loss is just a function of parameters .
The expected loss is
Since , . Therefore,
Extending to general cases
We spent a bunch of time trying to understand a simple 1D quadratic. Why care about a 1D quadratic?
Near a nice local minimum, a smooth loss looks quadratic. The 1D quadratic is the simplest local model of what noisy gradient descent sees when it is close to a minimum.
In 1D, if the minimum is at , then for nearby ,
So the same calculation applies locally, with curvature
In multiple dimensions, the same idea applies direction by direction. Near a minimum, the loss is approximately a quadratic bowl. The Hessian tells us the curvature in each local direction. Flatter directions have weaker force pulling the iterates back toward the minimum, so the noisy iterates spread out more along those directions; sharper directions have stronger force pulling the iterates back toward the minimum, so the cloud is narrower along those directions.
References
References are listed in alphabetical order.
- Gradient descent on neural networks typically occurs at the edge of stability [link]
Jeremy Cohen, Simran Kaur, Yuanzhi Li, J Zico Kolter, and Ameet Talwalkar. International Conference on Learning Representations. 2021. - Noise and fluctuation of finite learning rate stochastic gradient descent [link]
Kangqiao Liu, Liu Ziyin, and Masahito Ueda. Proceedings of the 38th International Conference on Machine Learning. 2021. - Acceleration of stochastic approximation by averaging [link]
B. T. Polyak and A. B. Juditsky. SIAM Journal on Control and Optimization. 1992.
Footnotes
-
This is the same basic stability threshold behind the “edge-of-stability” phenomenon: for a quadratic with curvature , gradient descent becomes unstable once the learning rate reaches . ↩