SGD Generalizes Better Than GD (And Regularization Doesn't Help)

Idan Amir, Tomer Koren, Roi Livni

Abstract

We present a fundamental separation result between the generalization performance of stochastic gradient descent (SGD) and full-batch gradient descent (GD) within the framework of stochastic convex optimization (SCO). While it is well-established that SGD requires $O(1/\epsilon^2)$ iterations to achieve an excess risk of $\epsilon$, we demonstrate that GD can severely overfit given the same number of iterations, resulting in an $\Omega(1)$ generalization error. Our analysis shows that $\Omega(1/\epsilon^4)$ iterations are necessary for GD to match the generalization performance of SGD—a bound that is tight. Furthermore, we show that explicit regularization of the empirical risk does not mitigate this gap, highlighting the unique role of algorithmic noise in generalization.

Introduction

In stochastic convex optimization (SCO), the goal is to minimize a population risk based on a finite set of samples. Two primary algorithms dominate this landscape: Stochastic Gradient Descent (SGD) and full-batch Gradient Descent (GD). SGD is widely celebrated for its efficiency and inherent generalization capabilities; by processing one fresh sample per iteration, it effectively navigates the population risk.

In contrast, full-batch GD utilizes the entire training set at every step, making it a form of Empirical Risk Minimization (ERM). While ERM is known to be prone to overfitting in high-dimensional settings, it was previously unclear whether the specific optimization path taken by GD might offer some form of implicit bias that prevents such overfitting. This research addresses a core theoretical question: Does GD generalize as well as SGD in a dimension-independent manner?

Methodology: Constructing the Counter-Example

The findings are based on a theoretical construction of a "worst-case" scenario. The authors design a loss function that satisfies standard assumptions—it is both convex and Lipschitz—but is specifically engineered to exploit the weaknesses of GD. This construction relies on two primary theoretical pillars:

  1. Algorithmic Instability: Building on previous research, the authors utilize the fact that GD can be highly unstable. In certain configurations, a marginal change in the training data can lead the algorithm to a drastically different solution.
  2. Uniform Convergence Failure: In high-dimensional spaces, there exist "bad" coordinates that appear to be minima on a specific training sample but perform poorly on the true underlying distribution.

By carefully correlating these "bad" coordinates with the trajectory of GD, the authors force the algorithm to "drift" toward a solution that achieves zero training error (ERM) but fails to generalize to the population, resulting in high generalization error.

The Generalization Gap: $1/\epsilon^2$ vs. $1/\epsilon^4$

The most significant contribution of this work is the quantitative separation between the two algorithms. For a target generalization error $\epsilon$:

  • SGD requires $O(1/\epsilon^2)$ iterations.
  • GD requires $\Omega(1/\epsilon^4)$ iterations.

This implies that if GD is run for the same number of steps as SGD, it may still emit a solution with constant error ($\Omega(1)$). To reach the same level of accuracy as SGD, GD requires a squared number of iterations. This gap suggests that the "noise" inherent in SGD’s sampling process is not merely a byproduct of efficiency but a critical feature that provides a powerful implicit regularization that GD lacks.

The Role of Regularization

A common prescription for overfitting in ERM is the addition of an explicit regularization term (e.g., $\lambda \|w\|^2$). However, this research yields a surprising result: regularization does not close the gap. Even when optimizing a regularized objective with an "optimal" choice of $\lambda$, GD still requires $\Omega(1/\epsilon^4)$ iterations to achieve $\epsilon$ generalization error. While regularization may assist in the convergence of the empirical objective, it does not accelerate the generalization process to match the efficiency of SGD.

Formal Results

The paper establishes two primary lower bounds:

  • Theorem 3.1 (GD Lower Bound): For any learning rate, there exists a convex Lipschitz problem where GD requires $\Omega(1/\epsilon^4)$ iterations to achieve $\epsilon$ generalization error. This matches recent upper bounds, proving the result is tight.
  • Theorem 3.2 (Regularized GD Lower Bound): The $\Omega(1/\epsilon^4)$ requirement persists even when an $\ell_2$ regularization term is added to the objective function.

Discussion and Limitations

While these results provide a definitive theoretical separation, they come with certain caveats. The adversarial examples constructed require the dimensionality $d$ of the problem to be very large, scaling with the number of iterations and samples. Whether GD exhibits similar overfitting in low-dimensional settings remains an open question.

Additionally, the study of early stopping remains incomplete. While early stopping is a known technique to prevent overfitting in GD, the current theoretical bounds suggest an "exponential gap" in our understanding of the optimal stopping time. Finally, while GD can fail in these adversarial settings, its success in practical applications suggests that real-world data distributions may possess structural properties that inhibit the specific type of drift demonstrated in this paper.

Summary updated

BibTeX
@inproceedings{amir2021sgd,
  author = {Idan Amir and Tomer Koren and Roi Livni},
  title = {{SGD Generalizes Better Than GD (And Regularization Doesn't Help)}},
  booktitle = {Conference on Learning Theory},
  year = {2021},
  url = {https://openreview.net/forum?id=Rzfc9ODrH1},
}
Figure