Skip to content
BIASED

Lagrange multipliers and KKT conditions

Block 1 of 7~2 min

When the gradient need not vanish

The topic Unconstrained optimization gave us a test for a minimum, ∇f(x∗)=0\nabla f(x^*) = 0, and gradient descent to find one. Many ML problems, however, restrict where xx may go. At a restricted minimum the gradient is usually not zero, so we need a new test.

Constraints are everywhere in ML:

  • class probabilities lie on the simplex: pi≥0p_i \ge 0 and ∑ipi=1\sum_i p_i = 1;
  • the first principal component is a unit vector: u⊤u=1u^\top u = 1;
  • a max-norm weight constraint or gradient clipping keeps a vector in a ball: ∥w∥≤r\lVert w \rVert \le r.

The general problem has inequality constraints gig_i and equality constraints hjh_j:

min⁡x f(x)s.t.gi(x)≤0,  i=1,…,m,hj(x)=0,  j=1,…,p.\min_x\ f(x) \quad \text{s.t.} \quad g_i(x) \le 0,\ \ i = 1, \dots, m, \qquad h_j(x) = 0,\ \ j = 1, \dots, p.

A point that satisfies all constraints is called feasible.

The running example of this topic is

min⁡x x12+2x22s.t.x1+x2=1.\min_x\ x_1^2 + 2x_2^2 \quad \text{s.t.} \quad x_1 + x_2 = 1.

Here the constraint can simply be eliminated. Substitute x1=1−x2x_1 = 1 - x_2: the function (1−x2)2+2x22(1 - x_2)^2 + 2x_2^2 is minimal at x2=13x_2 = \tfrac13. So x∗=(23,13)x^* = (\tfrac23, \tfrac13) and f∗=23f^* = \tfrac23. Note that ∇f(x∗)=(43,43)≠0\nabla f(x^*) = (\tfrac43, \tfrac43) \ne 0: the unconstrained test fails at a perfectly good minimum.

Elimination does not scale. A circle x12+x22=1x_1^2 + x_2^2 = 1 gives x2=±1−x12x_2 = \pm\sqrt{1 - x_1^2}: two branches and a square root. With nn constraints pi≥0p_i \ge 0, each one may hold with equality or not, which makes 2n2^n cases. We need a rule that works with the constraints as given.

Answers are saved on the server and tied to this browser until you sign in.