Md. Asif Uddin
Problem I.2.B07

The learning rule is a subgradient step

symbolic▲▲△

Symbolic throughout.

STATEMENT

The perceptron rule looks like a hand-made heuristic. Show that it is exactly one step of subgradient descent, with learning rate 11, on a specific loss — and identify that loss.

GIVEN

The perceptron loss for one example, sometimes called the hinge-at-zero loss:

(w,b)=max(0,  y(w,x+b))\ell(\vec{w}, b) = \max\big(0,\; -y(\langle\vec{w},\vec{x}\rangle + b)\big)

and the update rule of Definition 7: on a mistake, ww+yx\vec{w} \leftarrow \vec{w} + y\vec{x} and bb+yb \leftarrow b + y.

FIND

The subgradient of \ell with respect to w\vec{w} and bb in both regimes, and the resulting descent step at η=1\eta = 1.

STRATEGY

Split on the sign of the margin, differentiate each branch, and compare the resulting step with the rule. The function is not differentiable at the join, which is why “subgradient” rather than “gradient” — and that is a feature worth naming rather than glossing.

SOLUTION

Step 1 — name the inner quantity. Let m=y(w,x+b)m = y(\langle\vec{w},\vec{x}\rangle + b) be the functional margin, so =max(0,m)\ell = \max(0, -m).

Step 2 — the case m>0m > 0 (correct). Then m<0-m < 0, the maximum is achieved by the constant 00, and \ell is identically zero in a neighbourhood. A locally constant function has zero derivative:

w=0,/b=0\nabla_{\vec{w}}\,\ell = \vec{0}, \qquad \partial \ell/\partial b = 0

The descent step changes nothing. This matches the rule’s “otherwise do nothing” exactly.

Step 3 — the case m<0m < 0 (wrong). Then =m=y(w,x+b)\ell = -m = -y(\langle\vec{w},\vec{x}\rangle + b), which is affine in the parameters and so differentiable. Using ww,x=x\nabla_{\vec{w}}\langle\vec{w},\vec{x}\rangle = \vec{x} (The derivative of a linear map 0.MC.04):

w=yx,b=y\nabla_{\vec{w}}\,\ell = -y\vec{x}, \qquad \frac{\partial \ell}{\partial b} = -y

Step 4 — take a descent step. Gradient descent moves against the gradient (Gradient descent 0.OP.02), with η=1\eta = 1:

wwηw=w(1)(yx)=w+yx\vec{w} \leftarrow \vec{w} - \eta\,\nabla_{\vec{w}}\ell = \vec{w} - (1)(-y\vec{x}) = \vec{w} + y\vec{x}bbηb=b(1)(y)=b+yb \leftarrow b - \eta\,\frac{\partial\ell}{\partial b} = b - (1)(-y) = b + y

These are the update rule, term for term.

Step 5 — the join at m=0m = 0. At exactly zero the function has a kink and no derivative exists. The subdifferential is the whole interval between the two one-sided slopes, {αyx:α[0,1]}\{\,-\alpha\, y\vec{x} : \alpha \in [0,1]\,\}. Any element is a legal subgradient step; the perceptron picks α=1\alpha = 1, which is why it updates on m0m \le 0 rather than m<0m < 0. That convention, which looked arbitrary in I.2.B02, is a choice of subgradient.

Answer

The perceptron rule is subgradient descent on =max(0,y(w,x+b))\ell = \max(0, -y(\langle\vec{w},\vec{x}\rangle + b)) with η=1\eta = 1, taking the subgradient α=1\alpha = 1 at the kink:

w={0m>0yxm0ww+yx  on a mistake.\nabla_{\vec{w}}\,\ell = \begin{cases} \vec{0} & m > 0\\ -y\vec{x} & m \le 0 \end{cases} \qquad\Longrightarrow\qquad \vec{w} \leftarrow \vec{w} + y\vec{x} \ \text{ on a mistake.}

Check — sanity

The loss is zero exactly when the rule is idle. =0    m0    \ell = 0 \iff m \ge 0 \iff no update. The two descriptions of “nothing to do here” agree, which they must if one is to be a restatement of the other.

The loss is convex. It is the maximum of two affine functions of the parameters, and a pointwise maximum of convex functions is convex (Convexity 0.OP.01). So the perceptron is minimising a convex objective — and yet it still fails to terminate on XOR, because the minimum of that objective is not zero there. Convexity buys a well-posed problem, not a useful answer.

The learning rate is genuinely irrelevant here. Any η>0\eta > 0 gives ww+ηyx\vec{w} \leftarrow \vec{w} + \eta y\vec{x}, which rescales w\vec{w} but not the sign of any score when starting from 0\vec{0} — so the sequence of predictions is identical. This is unique to the perceptron and stops being true the moment Chapter I.4 introduces a loss with curvature.

Where this breaks

The identification needs η=1\eta = 1 and w0=0\vec{w}_0 = \vec{0} for the sequence to match; only the form of the step matches for general η\eta. It also needs the loss to be this one. The very similar hinge loss max(0,1m)\max(0, 1 - m) — which demands a margin of at least 11 rather than merely a correct sign — gives the same-shaped update but a different idle region, and converges to a maximum-margin solution the perceptron never finds. One symbol’s difference in the loss changes what the algorithm is for.

Variation

Derive the update for the hinge loss max(0,1m)\max(0, 1 - m) and state, in one sentence, what the extra 11 changes about which hyperplanes are stationary points.

Draws on