TL;DR

  1. Stability principle: if the output of an algorithm changes only a little when one training point is replaced, the algorithm generalizes. Unlike capacity bounds, this looks at the actual algorithm, not the whole function class.
  2. is with the -th point replaced by an independent . Average stability averages the loss change on the replaced point; uniform stability . Always .
  3. Proposition 1: : the expected generalization gap equals the average stability.
  4. Theorem 2: with loss bounded by and , with probability : . The gap vanishes iff .
  5. Stability alone does not give consistency (a constant predictor is perfectly stable); stability plus (approximate) ERM does.
  6. Theorem 3: ERM with a -strongly convex, -Lipschitz loss is uniformly stable with , independent of the complexity of . Theorems 4-6: GD and SGD on convex, -smooth, -Lipschitz losses with step sizes have (non-convex: ): fewer steps, more stable.

Exam relevance

  • Real exam, task type “algorithmic stability” (4 P): the bound of Theorem 2 is given together with a table of candidate rates (, , …); tick yes/no whether the bound goes to 0. Key fact: it vanishes iff . See the task and the widget.
  • Mock exam, task 6: uniform stability of the averaging rule with the squared loss, then what it implies (Proposition 1). Train it with the own-number version.
  • Multiple choice: vs. , stability vs. consistency, the assumptions of Theorem 3, why the plain squared loss is not strongly convex.
  • Sheet 5: 1-NN is not uniformly stable at rate but is stable on average; the averaging algorithm has ; stability of one-pass SGD.

Overview: 1. Motivation and definitions, 2. Stability implies generalization, 3. ERM with strongly convex loss is stable, 4. (S)GD on smooth losses is stable.

Motivation and key definitions

Why stability?

Slides 3-6

(Literature: Hardt and Recht Sec. 6.4, Mohri Sec. 11.2, Shalev-Shwartz and Ben-David Sec. 13.2. Key original references: Bousquet and Elisseeff 2002 for the standard bound; Shalev-Shwartz, Shamir, Srebro and Sridharan 2010 for “stability is sufficient and necessary for learning”; Hardt, Recht and Singer 2016 for the stability of SGD.)

Motivation 1. The standard approach of SLT proves generalization by bounding the capacity of the function class. This is often technically challenging and gives worst-case guarantees over all functions in the class instead of looking at the actual optimizers. In the perceptron bound (Lecture 2) we already saw the stability principle: if the result of a learning algorithm changes only a little when we fiddle with the data a little, the algorithm tends to generalize well.

Motivation 2. The LLN or the CLT hold as long as no single data point has much more influence than the others: the influence of one on the empirical average is “of the order “. Stability measures, in the same spirit, the influence of single data points on the empirical risk.

Definitions

Slides 7-10

Samples and notation

Two samples drawn i.i.d. from : and . The adapted sample replaces the -th point of by the -th point of :

Shorthand: and . or is the function learned by algorithm on , and the empirical risk on (analogously , ).

Average stability

For each we compare , trained on the original sample, with , trained with replaced by , both evaluated on . Note that is a test point for but a training point for .

Uniform stability

For and that differ in exactly one point, and a completely new test point (independent of both samples):

Obviously .

Mini example: the averaging algorithm (Sheet 5)

Regression on with the squared loss, for every . Replacing one label changes the prediction by . With the two predictions and a test label : . So .

Not every algorithm is uniformly stable

1-nearest neighbour (Sheet 5): on , replacing the one training point at can flip the prediction at a test point near , so the loss changes by 1 and , not . On average, though, a single point is the nearest neighbour of a random test point only with probability .

Algorithmic stability implies generalization

The expected generalization gap

Slides 11-14

(Literature: Mohri textbook.)

Proposition 1 (expected generalization gap equals average stability)

with the expectation over the training sample .

Discussion

This points in an interesting direction (bounding the generalization error by stability), but average stability is hard to evaluate. The stronger notion of uniform stability is easier to bound in practice and gives a nice high-probability bound, proved with McDiarmid’s inequality (Lecture 3).

Uniformly stable algorithms generalize

Slides 15-19

Theorem 2 (generalization bound for stable algorithms)

Assume the loss is bounded by a constant and let be the uniform stability of on samples. Then with probability at least over the samples :

Trap

On slide 16 the bound for term (2) reads ""; it should be (the loss bound), as on slide 18.

Discussion: which rates are good enough?

Slide 20

As soon as we can bound the uniform stability of an algorithm, we can plug it into Theorem 2. The key term is

and it goes to 0 if and as .

The condition to remember

The uniform stability needs to be of order to be useful. works; does not: then stays constant.

The gap of Theorem 2 for several rates βₙ against n. Switch on quiz mode to hide the answers and decide yes/no yourself, like in the exam table. The dashed curve is your own rate n^(−α).

Task: which stability rates are good enough?

Exam-style task: stability rates (4 P)

Use Theorem 2 with .

bound → 0?

(a) (1.5 P, easy) Fill in yes/no for each rate.

(b) (1 P, harder) Evaluate the gap for , and .

(c) (1.5 P, transfer) GD with constant step size has after steps (Theorem 4). How may the number of steps grow so that Theorem 2 still gives a vanishing gap?

Stability does not immediately imply consistency

Slides 21-22

Theorem 2 only says that for the function picked by the algorithm, . We do not (yet) know whether this function is anywhere close to the best in , nor to the Bayes predictor.

Counterexample

A naive algorithm that always predicts 0 is perfectly stable () and satisfies , but it is not the best in . For consistency we need a separate condition about the (empirical) risk of the classifier.

Stability + approximate ERM ⇒ consistency

Run ERM on a huge class ; if the ERM solution is uniformly stable, we get consistency:

Task: stability of an averaging rule

Exam-style task: an averaging rule with the absolute loss (4 P)

Labels , the algorithm predicts the mean label for every , and the loss is the absolute loss .

(a) (1 P, easy) Show that and differ pointwise by at most .

(b) (1.5 P, harder) Show and give the loss bound .

(c) (1.5 P, transfer) Evaluate the gap of Theorem 2 for , . What does the result say about , and what does it not say?

ERM with strongly convex loss function is stable

Motivation and strongly convex functions

Slides 23-27

(Literature: Hardt and Recht, Chapter 6, p. 111, Theorem 4.) Machine learning often minimizes a loss on training data (ERM). For small classes we can prove uniform convergence; if the class is too large for SLT, uniform stability might help. Question: is ERM uniformly stable? Answer: only under very strong assumptions on the loss.

-strongly convex

A differentiable on a convex domain is -strongly convex () if for all

In 1d with twice differentiable: convex iff , strongly convex if everywhere (a lower bound on the curvature). In : the smallest eigenvalue of the Hessian is at least .

A strongly convex function lies above its tangent plus a quadratic term
Slide 25: f lies above the tangent plus (μ/2)‖y − x‖².
A strongly convex function has a clear minimum; a merely convex function can have a flat bottom
Slide 27: strongly convex (left) vs. convex with a flat part (right).

If the loss is strongly convex, the empirical risk is strongly convex with the same . Then there always is a global optimum and it is not “hidden” in flat parts; GD and SGD easily find it.

Theorem 3: ERM is stable for strongly convex losses

Slides 28-33

Theorem 3 (ERM for strongly convex loss functions is stable)

Let each function in be parameterized by . Assume the loss is -strongly convex in and -Lipschitz in , for every . Then the empirical risk minimizer is uniformly stable with

First discussion

  • The theorem is about the empirical risk minimizer itself, not about an algorithm that tries to find it.
  • The complexity of does not show up anywhere. This is great.
  • scales as , so Theorem 2 gives a vanishing gap and, with the ERM argument above, consistency.
  • The assumptions are really strong. Promising, but not yet a solution for more complex losses.

Two small slips on the slides

Slide 31 writes on the right of step 1; since minimizes , the non-negative difference is . Slide 33 ends with ; the Lipschitz step adds a factor , giving as in the theorem.

Discussing the assumption

Slide 34

The squared loss of a linear model is not strongly convex

has gradient and Hessian . The Hessian has rank 1, so its smallest eigenvalue is 0 (for ): not strongly convex. Adding regularization makes it strongly convex, and this is the main use case of Theorem 3 (Lecture 5).

Task: applying Theorem 3

Exam-style task: stability of ERM from strong convexity (4 P)

One-dimensional parameter , labels , loss . ERM returns the mean label.

(a) (1 P, easy) Determine the strong convexity constant and a Lipschitz constant of the loss in on .

(b) (1.5 P, harder) What bound on does Theorem 3 give?

(c) (1.5 P, transfer) Compute directly as in the averaging example. How tight is Theorem 3 here? What changes for linear regression with parameters?

SGD is stable

Motivation: is SGD always stable?

Slides 35-39

(Literature: Hardt and Recht, Chapter 6, Theorem 6, p. 120; original paper: Hardt, Recht and Singer, “Train faster, generalize better: Stability of stochastic gradient descent”, ICML 2016.)

  • ERM is stable, but only under super-strong assumptions (strongly convex loss, a lower bound on the curvature), and the result is about the perfect minimizer, ignoring how to find it.
  • Now we look at a specific algorithm and the stability of its solutions: SGD.
  • We want uniform stability of order . SGD won’t be stable if it makes super-large steps that cannot be controlled, or if the loss landscape is super-fragmented so we cannot control where we jump. So we need assumptions.
A rugged three-dimensional loss surface of a neural network with many valleys and peaks
Slide 38: the loss landscape of a neural network (Li et al., NeurIPS 2018, "Visualizing the loss landscape of neural nets").

Beta-smooth functions

Slides 40-41

-smooth

A differentiable is -smooth if its gradient is -Lipschitz:

Smoothness is good for gradient methods: the gradient changes slowly, so after a small step it does not point in a completely different direction. While -strong convexity is a lower bound on the curvature, -smoothness is more like an upper bound.

Smooth losses

  • Squared loss for linear regression : convex and smooth with ; if it is -smooth. (The slide says “-smoothness”; with the constant is .)
  • Logistic loss : the Hessian satisfies , so it is smooth if is bounded.

Stability of gradient descent

Slides 42-47

To minimize : GD uses the full gradient, ; SGD samples one point per step, .

Theorem 4 (stability of GD)

Let the loss be continuously differentiable, convex, -smooth and -Lipschitz. Run GD with step sizes for steps from a fixed . Then the solution is uniformly stable with

Stability of SGD

Slides 48-51

Theorem 5 (stability of SGD, convex case)

Same assumptions (continuously differentiable, convex, -smooth, -Lipschitz), SGD with step sizes for steps:

The proof goes along similar lines but is more complicated because of the randomness: GD introduces a small bias at every step; SGD only seldom (when it updates on the changed sample), but then a larger change happens. Details: Hardt, Recht and Singer (and the assignments).

Theorem 6 (stability of SGD, non-convex case)

Assume the loss is -Lipschitz and -smooth (not necessarily convex), and run SGD for steps with decreasing step sizes . Then

Ignoring constants:

Depending on , this can be combined with Theorem 2 to get generalization (but not necessarily consistency).

  • These bounds are about stability; they do not yet guarantee consistency (how many steps ? convergence to an ERM minimizer?). Hardt, Recht and Singer give some guarantees for the convex setting.

Discussion and more results

Slides 52-53

  • The theorems on GD / SGD are the first results about an actual learning algorithm, not just an abstract empirical risk minimizer.
  • Depending on the number of steps we might or might not get stability of order , as needed in the generalization bound.
  • From the point of view of stability, fewer steps are better (a smaller generalization gap), but this ignores whether we get close enough to the actual minimizer. We revisit this with regularization (Lecture 5).
  • Stability has been proved for many algorithms: regularization, many kernel algorithms, GD / SGD in various (also non-convex) scenarios: SGD for deep networks (Hardt, Recht and Singer, ICML 2016), noisy SGD (Pensia, Jog and Loh, 2018), early stopping (Hardt, Ma and Recht, ICLR 2020), sharp vs. flat minima (Wu, Zhu et al., NeurIPS 2020).

Summary

ResultStatementAssumptions
Proposition 1none
Theorem 2loss ; useful iff
Stability + ERMconsistencyERM solution uniformly stable
Theorem 3 (ERM)-strongly convex, -Lipschitz; no complexity of
Theorems 4, 5 (GD, SGD)convex, -smooth, -Lipschitz,
Theorem 6 (SGD)non-convex,

Self-Test

Multiple Choice

References