Does It Always Converge? (Optional)

A short proof that on separable data the perceptron algorithm makes only a bounded number of corrections.

Deep Learning- Fundamentals to Advanced Concepts

Optional lesson

You can skip this and continue with the next lesson. It is here for readers who want to see why the algorithm is guaranteed to stop. The result is usually credited to Albert Novikoff (1962) and also appears in Minsky and Papert's book.

The worry from the previous lesson: correcting one example can upset another. Could the weights keep bouncing forever? If the data is linearly separable, no. The proof is short.

Setting up

To keep the algebra simple, use labels t=+1t = +1 for positive and t=−1t = -1 for negative examples. Then both update rules become a single one: on a mistake, w←w+t xw \leftarrow w + t\,x.

A mistake means t (w⋅x)≤0t\,(w \cdot x) \le 0. For a positive example that is w⋅x≤0w \cdot x \le 0, and for a negative one it is w⋅x≥0w \cdot x \ge 0. (The zero case is included, because a score of exactly 0 counts as positive.)

Assume the data is separable with some margin:

  • there is a unit-length vector w∗w^* and a number γ>0\gamma > 0 with t (w∗⋅x)≥γt\,(w^* \cdot x) \ge \gamma for every example, and
  • every example has length at most RR: ∥x∥≤R\|x\| \le R.

Start from w=0w = 0 and let wkw_k be the weights after kk corrections.

Two inequalities

1. The weights line up with w∗w^*. Each correction changes the overlap with w∗w^* by

w∗⋅wk=w∗⋅wk−1+t (w∗⋅x)≥w∗⋅wk−1+γw^* \cdot w_k = w^* \cdot w_{k-1} + t\,(w^* \cdot x) \ge w^* \cdot w_{k-1} + \gamma

After kk corrections, w∗⋅wk≥kγw^* \cdot w_k \ge k\gamma.

2. The weights cannot grow too fast. Since the last example was a mistake, t (wk−1⋅x)≤0t\,(w_{k-1} \cdot x) \le 0, so

∥wk∥2=∥wk−1∥2+2t (wk−1⋅x)+∥x∥2≤∥wk−1∥2+R2\|w_k\|^2 = \|w_{k-1}\|^2 + 2t\,(w_{k-1} \cdot x) + \|x\|^2 \le \|w_{k-1}\|^2 + R^2

After kk corrections, ∥wk∥2≤kR2\|w_k\|^2 \le kR^2.

Putting them together

Because w∗w^* has length 1, w∗⋅wk≤∥wk∥w^* \cdot w_k \le \|w_k\|. So

kγ  ≤  w∗⋅wk  ≤  ∥wk∥  ≤  k Rk\gamma \;\le\; w^* \cdot w_k \;\le\; \|w_k\| \;\le\; \sqrt{k}\,R

which gives

k  ≤  R2γ2k \;\le\; \frac{R^2}{\gamma^2}

The number of corrections is bounded. After at most R2/γ2R^2 / \gamma^2 corrections there are no more mistakes, which means a full pass is clean. That is convergence.

What the bound tells you

  • Bigger margin, faster learning. If the classes are well separated (large γ\gamma), few corrections are needed. A thin gap between classes means many.
  • The bound does not depend on the number of features or examples, only on RR and γ\gamma.
  • Random initial weights change the constant but not the conclusion.
Only for separable data

The proof needs w∗w^* to exist. If the data is not linearly separable, such as XOR, the algorithm never finds a clean pass. It keeps making corrections forever.

EasyConvergence

What does the convergence proof assume about the data?

HardConvergenceMath

According to the bound, how does halving the margin change the worst-case number of corrections?