Salta al contenuto
Note per Studenti Perceptron Convergence and the Margin Bound Report

Perceptron Convergence and the Margin Bound

In questa pagina 5

Question left open in Halfspaces and the Perceptron AlgorithmA perceptron computes h(x) = sign(w^T x) where x includes a constant coordinate x0 = 1 that absorbs the threshold into the bias weight w0; its decision boundary is the hyperplane w^T x = 0 (a line in the plane, x2 = -(w1/w2) x1 - w0/w2). The Perceptron Learning Algorithm scans the data and, on every misclassified point, replaces w by w + y x. A single perceptron cannot separate the exclusive-or pattern; two perceptrons feeding a third give a multilayer network.Halfspaces and the Perceptron Algorithm →: with the update rule wnew=wold+xiyi\mathbf{w}_{\text{new}}=\mathbf{w}_{\text{old}}+\mathbf{x}_iy_i, how many steps KK are needed to find a solution? The handwritten answer is a bound that depends only on the geometry of the data. First the distance from a point to a hyperplane, then the proof.

1. Distance of a point from the hyperplane

Setting of the sketch: the hyperplane h(x)h(\mathbf{x}), a point x\mathbf{x} off it, the vector w\mathbf{w} (perpendicular to the hyperplane), the point xp\mathbf{x}_p on the hyperplane nearest to x\mathbf{x}, and the vector γ\boldsymbol\gamma from xp\mathbf{x}_p to x\mathbf{x}, whose length is the distance between x\mathbf{x} and hh. Since the shortest segment to a hyperplane is perpendicular to it, γ∥w\boldsymbol\gamma\parallel\mathbf{w}, i.e. γ=αw\boldsymbol\gamma=\alpha\mathbf{w} for some number α\alpha, and

xp=x−γ.\mathbf{x}_p=\mathbf{x}-\boldsymbol\gamma .

(Here the bias is written separately: xp=[xp1,xp2]T\mathbf{x}_p=[x_{p1},x_{p2}]^T, w=[w1,w2]T\mathbf{w}=[w_1,w_2]^T, hyperplane wTx+b=0\mathbf{w}^T\mathbf{x}+b=0.)

Find α\alpha. xp\mathbf{x}_p lies on the hyperplane:

wTxp+b=0  ⟹  wT(x−γ)+b=0  ⟹  wTx−wTαw+b=0  ⟹  α wTw=wTx+b,\mathbf{w}^T\mathbf{x}_p+b=0\;\Longrightarrow\;\mathbf{w}^T(\mathbf{x}-\boldsymbol\gamma)+b=0\;\Longrightarrow\;\mathbf{w}^T\mathbf{x}-\mathbf{w}^T\alpha\mathbf{w}+b=0\;\Longrightarrow\;\alpha\,\mathbf{w}^T\mathbf{w}=\mathbf{w}^T\mathbf{x}+b,

  α=wTx+bwTw  \boxed{\;\alpha=\frac{\mathbf{w}^T\mathbf{x}+b}{\mathbf{w}^T\mathbf{w}}\;}

Find the length. With ∥γ∥=γTγ=γ12+⋯+γj2\|\boldsymbol\gamma\|=\sqrt{\boldsymbol\gamma^T\boldsymbol\gamma}=\sqrt{\gamma_1^2+\dots+\gamma_j^2}:

∥γ∥=αwTαw=α2 wTw=α2 wTw=(wTx+b)2(wTw)2  wTw=∣wTx+b∣wTwwTw.\|\boldsymbol\gamma\|=\sqrt{\alpha\mathbf{w}^T\alpha\mathbf{w}}=\sqrt{\alpha^2\,\mathbf{w}^T\mathbf{w}}=\sqrt{\alpha^2}\,\sqrt{\mathbf{w}^T\mathbf{w}} =\sqrt{\frac{(\mathbf{w}^T\mathbf{x}+b)^2}{(\mathbf{w}^T\mathbf{w})^2}}\;\sqrt{\mathbf{w}^T\mathbf{w}} =\frac{|\mathbf{w}^T\mathbf{x}+b|}{\mathbf{w}^T\mathbf{w}}\sqrt{\mathbf{w}^T\mathbf{w}}.

Simplifying,

  ∥γ∥=∣wTx+b∣wTw=∣wTx+b∣∥w∥  \boxed{\;\|\boldsymbol\gamma\|=\frac{|\mathbf{w}^T\mathbf{x}+b|}{\sqrt{\mathbf{w}^T\mathbf{w}}}=\frac{|\mathbf{w}^T\mathbf{x}+b|}{\|\mathbf{w}\|}\;}

In particular, if ∥w∥=1\|\mathbf{w}\|=1 the distance is simply ∣wTx+b∣|\mathbf{w}^T\mathbf{x}+b|; with the bias absorbed in x0=1x_0=1 it is ∣wTx∣|\mathbf{w}^T\mathbf{x}|.

2. Statement of the bound

Assumptions (sketch: a circle of radius RR containing all points, a separating hyperplane with normal w∗\mathbf{w}^*, and a band of half-width γ\gamma around it that contains no point):

  • the algorithm starts from the initial hypothesis w1=0\mathbf{w}_1=\mathbf{0};
  • there is an optimal hyperplane with coefficient vector w∗\mathbf{w}^*, ∥w∗∥=1\|\mathbf{w}^*\|=1 (that is w12+⋯+wj2=1\sqrt{w_1^2+\dots+w_j^2}=1), that classifies everything correctly with margin γ\gamma:

∀(xi,yi):(w∗Txi) yi≥γ;\forall(\mathbf{x}_i,y_i):\quad(\mathbf{w}^{*T}\mathbf{x}_i)\,y_i\ge\gamma ;

  • every point satisfies ∥xi∥≤R\|\mathbf{x}_i\|\le R.

Theorem. The number KK of updates that PLA performs before finding a solution satisfies

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

Indexing used in the proof: wK+1\mathbf{w}_{K+1} is the weight vector after KK updates (w1=0\mathbf{w}_1=\mathbf{0} after zero updates).

3. Proof in three steps

Step 1: wK+1Tw∗≥Kγ\mathbf{w}_{K+1}^T\mathbf{w}^*\ge K\gamma (induction on KK).

  • Base K=0K=0: w1=0\mathbf{w}_1=\mathbf{0}, so w1Tw∗=0≥0⋅γ\mathbf{w}_1^T\mathbf{w}^*=0\ge0\cdot\gamma, i.e. 0≥00\ge0.
  • Step K→K+1K\to K+1: the update on a misclassified point (xi,yi)(\mathbf{x}_i,y_i) gives wK+2Tw∗=(wK+1+yixi)Tw∗=wK+1Tw∗+yixiTw∗≥Kγ+γ=(K+1)γ,\mathbf{w}_{K+2}^T\mathbf{w}^*=(\mathbf{w}_{K+1}+y_i\mathbf{x}_i)^T\mathbf{w}^*=\mathbf{w}_{K+1}^T\mathbf{w}^*+y_i\mathbf{x}_i^T\mathbf{w}^*\ge K\gamma+\gamma=(K+1)\gamma, using the induction hypothesis for the first term and the margin assumption (w∗Txi)yi≥γ(\mathbf{w}^{*T}\mathbf{x}_i)y_i\ge\gamma for the second.

Step 2: ∥wK+1∥≥Kγ\|\mathbf{w}_{K+1}\|\ge K\gamma. From the cosine formula, with θ\theta the angle between wK+1\mathbf{w}_{K+1} and w∗\mathbf{w}^*,

wK+1Tw∗=∥wK+1∥ ∥w∗∥cos⁡θ≤∥wK+1∥ ∥w∗∥,\mathbf{w}_{K+1}^T\mathbf{w}^*=\|\mathbf{w}_{K+1}\|\,\|\mathbf{w}^*\|\cos\theta\le\|\mathbf{w}_{K+1}\|\,\|\mathbf{w}^*\|,

because cos⁡θ≤1\cos\theta\le1. With ∥w∗∥=1\|\mathbf{w}^*\|=1 and Step 1:

Kγ≤wK+1Tw∗≤∥wK+1∥.K\gamma\le\mathbf{w}_{K+1}^T\mathbf{w}^*\le\|\mathbf{w}_{K+1}\|.

Step 3: ∥wK+1∥2≤K R2\|\mathbf{w}_{K+1}\|^2\le K\,R^2 (induction on KK).

  • Base K=0K=0: ∥w1∥2=0≤0⋅R2\|\mathbf{w}_1\|^2=0\le0\cdot R^2.
  • Step: ∥wK+2∥2=∥wK+1+xiyi∥2=∥wK+1∥2+∥xiyi∥2+2 wK+1T yixi.\|\mathbf{w}_{K+2}\|^2=\|\mathbf{w}_{K+1}+\mathbf{x}_iy_i\|^2=\|\mathbf{w}_{K+1}\|^2+\|\mathbf{x}_iy_i\|^2+2\,\mathbf{w}_{K+1}^T\,y_i\mathbf{x}_i . The last (cross) term is not positive: the update is performed only when the point is misclassified, i.e. yi wK+1Txi≤0y_i\,\mathbf{w}_{K+1}^T\mathbf{x}_i\le0 (the handwritten page marks it "<0<0"; "≤0\le0" is enough for the argument). Dropping it, ∥wK+2∥2≤∥wK+1∥2+∥xiyi∥2=∥wK+1∥2+∥xi∥2≤∥wK+1∥2+R2≤KR2+R2=(K+1)R2.\|\mathbf{w}_{K+2}\|^2\le\|\mathbf{w}_{K+1}\|^2+\|\mathbf{x}_iy_i\|^2=\|\mathbf{w}_{K+1}\|^2+\|\mathbf{x}_i\|^2\le\|\mathbf{w}_{K+1}\|^2+R^2\le KR^2+R^2=(K+1)R^2 . The equality ∥xiyi∥=∥xi∥\|\mathbf{x}_iy_i\|=\|\mathbf{x}_i\| holds because yi=±1y_i=\pm1; the next inequality because all points are inside the circle of radius RR.

Conclusion. Squaring Step 2 (both sides are non-negative) and using Step 3,

K2γ2≤∥wK+1∥2≤K R2  ⟹  K≤R2γ2.K^2\gamma^2\le\|\mathbf{w}_{K+1}\|^2\le K\,R^2\;\Longrightarrow\;K\le\frac{R^2}{\gamma^2}.

4. How to read the bound

  • Small margin means many steps. The last sketches of the page contrast a data set whose clouds are far from the separating line (large γ\gamma) with one where points almost touch it (small γ\gamma, big R2/γ2R^2/\gamma^2).
  • The bound does not depend on the number of points or on the number of features, only on RR and γ\gamma (my remark).
  • It counts updates, not passes over the data: each pass over the data of the notebooks is an epoch and may contain many updates or none.
  • It assumes the data are linearly separable. For non-separable data (the last sketch of the page, with a curved boundary needed) the algorithm never stops, so the code adds a maximum number of iterations. Many separating lines may exist (the bundle of lines in the sketch): PLA returns one of them, not a particular one.

5. Notation page

The last page of this lecture recalls notation: a column vector X=[x1,x2,x3,x4]TX=[x_1,x_2,x_3,x_4]^T and its transpose XT=[x1  x2  x3  x4]X^T=[x_1\;x_2\;x_3\;x_4]; a matrix Y=[y1y2y3y4]Y=\begin{bmatrix}y_1&y_2\\y_3&y_4\end{bmatrix} and its transpose YT=[y1y3y2y4]Y^T=\begin{bmatrix}y_1&y_3\\y_2&y_4\end{bmatrix}; the norm ∥X∥=x12+x22+x32+x42\|X\|=\sqrt{x_1^2+x_2^2+x_3^2+x_4^2}. See also Vector Spaces, Scalar Product and NormsReview of geometry for signals: vector spaces over a field, the scalar product and norm in complex vector spaces, p-norms, orthogonality, and the generalized Pythagorean theorem.Vector Spaces, Scalar Product and Norms →.

Versione ripasso

Perceptron Convergence and the Margin Bound

Teoria collegata