1 of 18

Lecture 4: �Optimization

André E. Lazzaretti

UTFPR/CPGEI

2 of 18

Optimization

  • Why optimization?
    • In pattern recognition, the goal is often to optimize (maximize or minimize) a specific mathematical function (cost function, loss function, objective function).

​

  • For example:
    • Least squares

​

  • General framework: formulate the function and perform the optimization

​

  • Optimization:
    • Unconstrained
    • Constrained

​

​

3 of 18

Unconstrained Optimization

​

​

  • g(x) → cost/loss function
  • x = [x1, x2, ... , xn] → variables to be optimized

4 of 18

Unconstrained Optimization

​

​

  • ∇g(x) → gradient of g(x)
    • Provides the direction of the greatest slope (variation) of g(x)
    • Negative Direction of ∇g(x): Direction of steepest descent

5 of 18

Unconstrained Optimization

  • Global Minimum
    • x* is a global minimum if

6 of 18

Unconstrained Optimization

  • Local minimum:

​

  • Optimality conditions:
    • Necessary condition: if g(x) is continuously differentiable (first-order condition):

​

​

​

​

​

7 of 18

Unconstrained Optimization

  • Sufficient condition: if every element of ∇2g(x) is a continuous function, ∇2g(x) evaluated for x = x* must be positive definite for x* to be a local minimum point (second-order condition):

​

​

​

​

​

​

  • A matrix Ω is positive definite if all eigenvalues λi, i = 1, 2, ..., n, of Ω Ω are positive.
  • Null gradient: saddle point, maximum, or minimum.
    • Negative definite – maximum
    • Positive and negative eigenvalues: saddle point

8 of 18

Unconstrained Optimization

  • Necessary and sufficient conditions for x* to be a local minimum point:

​

​

    • H(x) evaluated for x = x* must be positive definite

​

    • If g(x) is convex and x* satisfies the first-order condition, then x* is a global minimum point.

Convex function: all local minima are global minima(*).

Non-convex function

9 of 18

How to solve it?

  • Normally: ∇g(x)=0

​

  • This solution is viable when ∇g(x)=0 forms a linear system of equations;

​

  • If this is not possible (nonlinear system of equations) → alternatives;

​

  • Alternative – Iterative methods:
    • Gradient descent;
    • Newton's method.

​

​

​

​

10 of 18

Optimization using Gradient

11 of 18

Example

(x1)2 + x1x2 + 10(x2)2 – 5x1 – 3x2

​

1) Calculate the gradient.

​

2) Write in the following form:

​

​

​

​

3) Calculate the gradient using:

​

​

​

4) Write it as:

​

A

b

C

d

12 of 18

Example

13 of 18

Example

14 of 18

Example

15 of 18

Example

16 of 18

Example

17 of 18

Problems with gradient

18 of 18

Newton’s method

  • Use the following:

​

​

​

  • This method is derived by assuming a second-order approximation (via a Taylor series) of the function at the point in question:

​

  • Exercise – verify!

​

​

or