Docsity

Convex Optimization Overview - Lectures Handouts - Part 1, Study notes of Machine Learning

Toggle sidebar
bg1
Convex Optimization Overview
Zico Kolter
October 19, 2007
1 Introduction
Many situations arise in machine learning where we would like to optimize the value of
some function. That is, given a function f:Rn→R, we want to find x∈Rnthat minimizes
(or maximizes) f(x). We have already seen several examples of optimization problems in
class: least-squares, logistic regression, and support vector machines can all be framed as
optimization problems.
It turns out that in the general case, finding the global optimum of a function can be a
very difficult task. However, for a special class of optimization problems, known as convex
optimization problems, we can efficiently find the global solution in many cases. Here,
“efficiently” has both practical and theoretical connotations: it means that we can solve
many real-world problems in a reasonable amount of time, and it means that theoretically
we can solve problems in time that depends only polynomially on the problem size.
The goal of these section notes and the accompanying lecture is to give a very brief
overview of the field of convex optimization. Much of the material here (including some
of the figures) is heavily based on the book Convex Optimization [1] by Stephen Boyd and
Lieven Vandenberghe (available for free online), and EE364, a class taught here at Stanford
by Stephen Boyd. If you are interested in pursuing convex optimization further, these are
both excellent resources.
2 Convex Sets
We begin our look at convex optimization with the notion of a convex set.
Definition 2.1 A set Cis convex if, for any x, y ∈Cand θ∈Rwith 0≤θ≤1,
θx + (1 −θ)y∈C.
Intuitively, this means that if we take any two elements in C, and draw a line segment
between these two elements, then every point on that line segment also belongs to C. Figure
1 shows an example of one convex and one non-convex set. The point θx + (1 −θ)yis called
aconvex combination of the points xand y.
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Convex Optimization Overview - Lectures Handouts - Part 1 and more Study notes Machine Learning in PDF only on Docsity!

Convex Optimization Overview

Zico Kolter

October 19, 2007

1 Introduction

Many situations arise in machine learning where we would like to optimize the value of some function. That is, given a function f : Rn^ → R, we want to find x ∈ Rn^ that minimizes (or maximizes) f (x). We have already seen several examples of optimization problems in class: least-squares, logistic regression, and support vector machines can all be framed as optimization problems. It turns out that in the general case, finding the global optimum of a function can be a very difficult task. However, for a special class of optimization problems, known as convex optimization problems, we can efficiently find the global solution in many cases. Here, “efficiently” has both practical and theoretical connotations: it means that we can solve many real-world problems in a reasonable amount of time, and it means that theoretically we can solve problems in time that depends only polynomially on the problem size. The goal of these section notes and the accompanying lecture is to give a very brief overview of the field of convex optimization. Much of the material here (including some of the figures) is heavily based on the book Convex Optimization [1] by Stephen Boyd and Lieven Vandenberghe (available for free online), and EE364, a class taught here at Stanford by Stephen Boyd. If you are interested in pursuing convex optimization further, these are both excellent resources.

2 Convex Sets

We begin our look at convex optimization with the notion of a convex set.

Definition 2.1 A set C is convex if, for any x, y ∈ C and θ ∈ R with 0 ≤ θ ≤ 1 ,

θx + (1 − θ)y ∈ C.

Intuitively, this means that if we take any two elements in C, and draw a line segment between these two elements, then every point on that line segment also belongs to C. Figure 1 shows an example of one convex and one non-convex set. The point θx + (1 − θ)y is called a convex combination of the points x and y.

(a) (b) Figure 1: Examples of a convex set (a) and a non-convex set (b).

2.1 Examples

  • All of Rn. It should be fairly obvious that given any x, y ∈ Rn, θx + (1 − θ)y ∈ Rn.
  • The non-negative orthant, Rn +. The non-negative orthant consists of all vectors in Rn^ whose elements are all non-negative: Rn + = {x : xi ≥ 0 ∀i = 1,... , n}. To show that this is a convex set, simply note that given any x, y ∈ Rn + and 0 ≤ θ ≤ 1,

(θx + (1 − θ)y)i = θxi + (1 − θ)yi ≥ 0 ∀i.

  • Norm balls.√∑ Let ‖ · ‖ be some norm on Rn^ (e.g., the Euclidean norm, ‖x‖ 2 = n i=1 x

2 i ). Then the set^ {x^ :^ ‖x‖ ≤^1 }^ is a convex set. To see this, suppose^ x, y^ ∈^ R n, with ‖x‖ ≤ 1 , ‖y‖ ≤ 1, and 0 ≤ θ ≤ 1. Then

‖θx + (1 − θ)y‖ ≤ ‖θx‖ + ‖(1 − θ)y‖ = θ‖x‖ + (1 − θ)‖y‖ ≤ 1

where we used the triangle inequality and the positive homogeneity of norms.

  • Affine subspaces and polyhedra. Given a matrix A ∈ Rm×n^ and a vector b ∈ Rm, an affine subspace is the set {x ∈ Rn^ : Ax = b} (note that this could possibly be empty if b is not in the range of A). Similarly, a polyhedron is the (again, possibly empty) set {x ∈ Rn^ : Ax  b}, where ‘’ here denotes componentwise inequality (i.e., all the entries of Ax are less than or equal to their corresponding element in b).^1 To prove this, first consider x, y ∈ Rn^ such that Ax = Ay = b. Then for 0 ≤ θ ≤ 1,

A(θx + (1 − θ)y) = θAx + (1 − θ)Ay = θb + (1 − θ)b = b.

Similarly, for x, y ∈ Rn^ that satisfy Ax ≤ b and Ay ≤ b and 0 ≤ θ ≤ 1,

A(θx + (1 − θ)y) = θAx + (1 − θ)Ay ≤ θb + (1 − θ)b = b. (^1) Similarly, for two vectors x, y ∈ Rn, x  y denotes that each element of X is greater than or equal to the

corresponding element in b. Note that sometimes ‘≤’ and ‘≥’ are used in place of ‘’ and ‘’; the meaning must be determined contextually (i.e., both sides of the inequality will be vectors).

Figure 2: Graph of a convex function. By the definition of convex functions, the line con- necting two points on the graph must lie above the function.

3.1 First Order Condition for Convexity

Suppose a function f : Rn^ → R is differentiable (i.e., the gradient^3 ∇xf (x) exists at all points x in the domain of f ). Then f is convex if and only if D(f ) is a convex set and for all x, y ∈ D(f ), f (y) ≥ f (x) + ∇xf (x)T^ (y − x).

The function f (x) + ∇xf (x)T^ (y − x) is called the first-order approximation to the function f at the point x. Intuitively, this can be thought of as approximating f with its tangent line at the point x. The first order condition for convexity says that f is convex if and only if the tangent line is a global underestimator of the function f. In other words, if we take our function and draw a tangent line at any point, then every point on this line will lie below the corresponding point on f. Similar to the definition of convexity, f will be strictly convex if this holds with strict inequality, concave if the inequality is reversed, and strictly concave if the reverse inequality is strict.

Figure 3: Illustration of the first-order condition for convexity.

(^3) Recall that the gradient is defined as ∇xf (x) ∈ Rn, (∇xf (x))i = ∂f^ (x) ∂xi. For a review on gradients and Hessians, see the previous section notes on linear algebra.

3.2 Second Order Condition for Convexity

Suppose a function f : Rn^ → R is twice differentiable (i.e., the Hessian^4 ∇^2 xf (x) is defined for all points x in the domain of f ). Then f is convex if and only if D(f ) is a convex set and its Hessian is positive semidefinite: i.e., for any x ∈ D(f ),

∇^2 xf (x)  0.

Here, the notation ‘’ when used in conjunction with matrices refers to positive semidefi- niteness, rather than componentwise inequality. 5 In one dimension, this is equivalent to the condition that the second derivative f ′′(x) always be positive (i.e., the function always has positive curvature). Again analogous to both the definition and first order conditions for convexity, f is strictly convex if its Hessian is positive definite, concave if the Hessian is negative semidefinite, and strictly concave if the Hessian is negative definite.

3.3 Jensen’s Inequality

Suppose we start with the inequality in the basic definition of a convex function

f (θx + (1 − θ)y) ≤ θf (x) + (1 − θ)f (y) for 0 ≤ θ ≤ 1.

Using induction, this can be fairly easily extended to convex combinations of more than one point,

f

( (^) k ∑

i=

θixi

∑^ k

i=

θif (xi) for

∑^ k

i=

θi = 1, θi ≥ 0 ∀i.

In fact, this can also be extended to infinite sums or integrals. In the latter case, the inequality can be written as

f

p(x)xdx

p(x)f (x)dx for

p(x)dx = 1, p(x) ≥ 0 ∀x.

Because p(x) integrates to 1, it is common to consider it as a probability density, in which case the previous equation can be written in terms of expectations,

f (E[x]) ≤ E[f (x)].

This last inequality is known as Jensen’s inequality, and it will come up later in class.^6

(^4) Recall the Hessian is defined as ∇ (^2) xf (x) ∈ Rn×n, (∇ (^2) xf (x))ij = ∂^2 f^ (x) ∂xi∂xj (^5) Similarly, for a symmetric matrix X ∈ Sn, X  0 denotes that X is negative semidefinite. As with vector inequalities, ‘≤’ and ‘≥’ are sometimes used in place of ‘’ and ‘’. Despite their notational similarity to vector inequalities, these concepts are very different; in particular, X  0 does not imply that Xij ≥ 0 for all i and j. (^6) In fact, all four of these equations are sometimes referred to as Jensen’s inequality, due to the fact that

they are all equivalent. However, for this class we will use the term to refer specifically to the last inequality presented here.

  • Norms. Let f : Rn^ → R be some norm on Rn. Then by the triangle inequality and positive homogeneity of norms, for x, y ∈ Rn, 0 ≤ θ ≤ 1,

f (θx + (1 − θ)y) ≤ f (θx) + f ((1 − θ)y) = θf (x) + (1 − θ)f (y).

This is an example of a convex function where it is not possible to prove convexity based on the second or first order conditions, because norms are not generally differentiable everywhere (e.g., the 1-norm, ||x|| 1 =

∑n i=1 |xi|, is non-differentiable at all points where any xi is equal to zero).

  • Nonnegative weighted sums of convex functions. Let f 1 , f 2 ,... , fk be convex functions and w 1 , w 2 ,... , wk be nonnegative real numbers. Then

f (x) =

∑^ k

i=

wifi(x)

is a convex function, since

f (θx + (1 − θ)y) =

∑^ k

i=

wifi(θx + (1 − θ)y)

∑^ k

i=

wi(θfi(x) + (1 − θ)fi(y))

= θ

∑^ k

i=

wifi(x) + (1 − θ)

∑^ k

i=

wifi(y)

= θf (x) + (1 − θ)f (x).

4 Convex Optimization Problems

Armed with the definitions of convex functions and sets, we are now equipped to consider convex optimization problems. Formally, a convex optimization problem in an opti- mization problem of the form minimize f (x) subject to x ∈ C

where f is a convex function, C is a convex set, and x is the optimization variable. However, since this can be a little bit vague, we often write it often written as

minimize f (x) subject to gi(x) ≤ 0 , i = 1,... , m hi(x) = 0, i = 1,... , p

where f is a convex function, gi are convex functions, and hi are affine functions, and x is the optimization variable.

Is it imporant to note the direction of these inequalities: a convex function gi must be less than zero. This is because the 0-sublevel set of gi is a convex set, so the feasible region, which is the intersection of many convex sets, is also convex (recall that affine subspaces are convex sets as well). If we were to require that gi ≥ 0 for some convex gi, the feasible region would no longer be a convex set, and the algorithms we apply for solving these problems would not longer be guaranteed to find the global optimum. Also notice that only affine functions are allowed to be equality constraints. Intuitively, you can think of this as being due to the fact that an equality constraint is equivalent to the two inequalities hi ≤ 0 and hi ≥ 0. However, these will both be valid constraints if and only if hi is both convex and concave, i.e., hi must be affine. The optimal value of an optimization problem is denoted p⋆^ (or sometimes f ⋆) and is equal to the minimum possible value of the objective function in the feasible region^7

p⋆^ = min{f (x) : gi(x) ≤ 0 , i = 1,... , m, hi(x) = 0, i = 1,... , p}.

We allow p⋆^ to take on the values +∞ and −∞ when the problem is either infeasible (the feasible region is empty) or unbounded below (there exists feasible points such that f (x) → −∞), respectively. We say that x⋆^ is an optimal point if f (x⋆) = p⋆. Note that there can be more than one optimal point, even when the optimal value is finite.

4.1 Global Optimality in Convex Problems

Before stating the result of global optimality in convex problems, let us formally define the concepts of local optima and global optima. Intuitively, a feasible point is called locally optimal if there are no “nearby” feasible points that have a lower objective value. Similarly, a feasible point is called globally optimal if there are no feasible points at all that have a lower objective value. To formalize this a little bit more, we give the following two definitions.

Definition 4.1 A point x is locally optimal if it is feasible (i.e., it satisfies the constraints of the optimization problem) and if there exists some R > 0 such that all feasible points z with ‖x − z‖ 2 ≤ R, satisfy f (x) ≤ f (z).

Definition 4.2 A point x is globally optimal if it is feasible and for all feasible points z, f (x) ≤ f (z).

We now come to the crucial element of convex optimization problems, from which they derive most of their utility. The key idea is that for a convex optimization problem all locally optimal points are globally optimal. Let’s give a quick proof of this property by contradiction. Suppose that x is a locally optimal point which is not globally optimal, i.e., there exists a feasible point y such that

(^7) Math majors might note that the min appearing below should more correctly be an inf. We won’t worry about such technicalities here, and use min for simplicity.

where again x ∈ Rn^ is the optimization variable, c ∈ Rn, d ∈ R, G ∈ Rm×n, h ∈ Rm, A ∈ Rp×n, b ∈ Rp^ are defined by the problem, but we also have P ∈ Sn +, a symmetric positive semidefinite matrix.

  • Quadratically Constrained Quadratic Programming. We say that a convex optimization problem is a quadratically constrained quadratic program (QCQP) if both the objective f and the inequality constraints gi are convex quadratic functions,

minimize 12 xT^ P x + cT^ x + d subject to 12 xT^ Qix + rTi x + si ≤ 0 , i = 1,... , m Ax = b

where, as before, x ∈ Rn^ is the optimization variable, c ∈ Rn, d ∈ R, A ∈ Rp×n, b ∈ Rp, P ∈ Sn +, but we also have Qi ∈ Sn +, ri ∈ Rn, si ∈ R, for i = 1,... , m.

  • Semidefinite Programming. This last example is a bit more complex than the pre- vious ones, so don’t worry if it doesn’t make much sense at first. However, semidefinite programming is become more and more prevalent in many different areas of machine learning research, so you might encounter these at some point, and it is good to have an idea of what they are. We say that a convex optimization problem is a semidefinite program (SDP) if it is of the form

minimize tr(CX) subject to tr(AiX) = bi, i = 1,... , p X  0

where the symmetric matrix X ∈ Sn^ is the optimization variable, the symmetric ma- trices C, A 1 ,... , Ap ∈ Sn^ are defined by the problem, and the constraint X  0 means that we are constraining X to be positive semidefinite. This looks a bit different than the problems we have seen previously, since the optimization variable is now a matrix instead of a vector. If you are curious as to why such a formulation might be useful, you should look into a more advanced course or book on convex optimization.

It should be fairly obvious from the definitions that quadratic programs are more general than linear programs (since a linear program is just a special case of a quadratic program where P = 0), and likewise that quadratically constrained quadratic programs are more general than quadratic programs. However, what is not obvious at all is that semidefinite programs are in fact more general than all the previous types. That is, any quadratically constrained quadratic program (and hence any quadratic program or linear program) can be expressed as a semidefinte program. We won’t discuss this relationship further in this document, but this might give you just a small idea as to why semidefinite programming could be useful.

4.3 Examples

Now that we’ve covered plenty of the boring math and formalisms behind convex optimiza- tion, we can finally get to the fun part: using these techniques to solve actual problems. We’ve already encountered a few such optimization problems in class, and in nearly every field, there is a good chance that someone has tried to apply convex optimization to solve some problem.

  • Support Vector Machines. One of the most prevalent applications of convex op- timization methods in machine learning is the support vector machine classifier. As discussed in class, finding the support vector classifier (in the case with slack variables) can be formulated as the optimization problem minimize 12 ‖w‖^22 + C

∑m i=1 ξi subject to y(i)(wT^ x(i)^ + b) ≥ 1 − ξi, i = 1,... , m ξi ≥ 0 , i = 1,... , m

with optimization variables w ∈ Rn, ξ ∈ Rm, b ∈ R, and where C ∈ R and x(i), y(i), i = 1 ,... m are defined by the problem. This is an example of a quadratic program, which we try to put the problem into the form described in the previous section. In particular, if define k = m + n + 1, let the optimization variable be

x ∈ Rk^ ≡

w ξ b

and define the matrices

P ∈ Rk×k^ =

I 0 0

 (^) , c ∈ Rk^ =

C · 1

G ∈ R^2 m×k^ =

[

−diag(y)X −I −y 0 −I 0

]

, h ∈ R^2 m^ =

[

]

where I is the identity, 1 is the vector of all ones, and X and y are defined as in class,

X ∈ Rm×n^ =

x(1) T

x(2) T .. . x(m) T

, y ∈ Rm^ =

y(1) y(2) .. . y(m)

You should try to convince yourself that the quadratic program described in the pre- vious section, when using these matrices defined above, is equivalent to the SVM optimization problem. In reality, it is fairly easy to see that there the SVM optimiza- tion problem has a quadratic objective and linear constraints, so we typically don’t need to put it into standard form to “prove” that it is a QP, and would only do so if we are using an off-the-shelf solver that requires the input to be in standard form.