1 / 35

Gradient Descent

Gradient Descent. Slides adapted from David Kauchak , Michael T. Brannick , Ethem Alpaydin , and Yaser Abu-Mostafa. Linear models. A strong high-bias assumption is linear separability : in 2 dimensions, can separate classes by a line in higher dimensions, need hyperplanes

jahlers
Download Presentation

Gradient Descent

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Gradient Descent Slides adapted from David Kauchak, Michael T. Brannick, EthemAlpaydin, and Yaser Abu-Mostafa

  2. Linear models A strong high-bias assumption is linear separability: • in 2 dimensions, can separate classes by a line • in higher dimensions, need hyperplanes A linear model assumes the data is linearly separable

  3. Linear models bias A linear model in n-dimensional space (i.e. n features) is defined by n+1 weights: In two dimensions, a line: In three dimensions, a plane: Generally, in m-dimensions, a hyperplane:

  4. Perceptron Learning Algorithm (PLA)

  5. A closer look at PLA Current weights: (0, 0, 1) Current example: (1, -1, -1) + bias We’d like this value to be positive since it’s a positive example contributed in the wrong direction didn’t contribute, but could have increase decrease decrease 0 -> 1 0 -> -1 1 -> 0

  6. Which line will it find?

  7. Which line will it find? Only guaranteed to find some line that separates the data

  8. Linear models • Perceptron algorithm is one example of a linear classifier • Many, many other algorithms that learn a line (i.e. a setting of a linear combination of weights) • Goals: • Explore a number of linear training algorithms • Understand why these algorithms work

  9. Model-based machine learning • pick a model • e.g. a hyperplane, a decision tree,… • A model is defined by a collection of parameters • pick a criterion to optimize (aka objective function) • e.g. training error • develop a learning algorithm • the algorithm should try and minimize the criteria • sometimes in a heuristic way (i.e. non-optimally), sometimes exactly

  10. Linear Models • pick a model • pick a criteria to optimize (aka objective function) • develop a learning algorithmFind w and b that minimize the 0/1 loss (i.e. training error) These are the parameters we want to learn Indicator Function

  11. 0/1 loss function • distance from hyperplane • sign is prediction whether or not the prediction and label agree, true if they don’t total number of mistakes, aka 0/1 loss

  12. Linear Models • pick a model • pick a criteria to optimize (aka objective function) • develop a learning algorithmFind w and b that minimize the 0/1 loss (i.e. training error) These are the parameters we want to learn

  13. Minimizing 0/1 loss Find w and b that minimize the 0/1 loss

  14. Minimizing 0/1 in one dimension Why is it hard to minimize this function? loss w Each time we change w such that the example is right/wrong the loss will increase/decrease

  15. Minimizing 0/1 over all w Each feature (i.e. weight) represents another dimension to this space! loss

  16. Minimizing 0/1 loss Find w and b that minimize the 0/1 loss This turns out to be hard (in fact, NP-HARD ) • Challenges: • small changes in some w can have large effect on loss • large changes in some w can have no effect on loss • there can be many, many local minima • at any given point, not much information to lead to any minima

  17. More manageable loss functions loss w What property/properties do we want from our loss function?

  18. More manageable loss functions loss w • Ideally, continuous (i.e. differentiable) so we get an indication of direction of minimization • Only one minima

  19. Convex functions • Smooth, continuous • Local = global minimum • Line segment between any two points on the function • is above the function • Stays “inside” function Convex Non-convex

  20. Surrogate loss functions • For many applications, we really would like to minimize the 0/1 loss • A surrogate loss function is a loss function that provides an upper bound on the actual loss function (in this case, 0/1) • convex surrogate loss functions should be easier to minimize • Key to a loss function: how it scores the difference between the actual label y and the predicted label y’

  21. Surrogate loss functions 0/1 loss: Hinge: Exponential: Squared loss:

  22. Surrogate loss functions Hinge: 0/1 (classification) loss: Exponential: Squared (Quadratic) loss:

  23. Linear Model Learning w/ Surrogate Loss use a convex surrogate loss function (e.g., exponential) Find w and b that minimize surrogate loss pick a model pick a criteria to optimize (aka objective function) develop a learning algorithm

  24. Minimizing convex loss function Find w and b that minimize the surrogate loss loss w How do we do this now?

  25. One approach: gradient descent Partial derivatives give us the slope (i.e. direction to move) in that dimension loss w

  26. One approach: gradient descent Partial derivatives give us the slope (i.e. direction to move) in that dimension Approach: • pick a starting point (w) • repeat: • pick a dimension • move a small amount in that dimension towards decreasing loss (using the derivative) loss w

  27. Gradient descent • pick a starting point (w) • repeat until loss doesn’t decrease in any dimension: • pick a dimension • move a small amount in that dimension towards decreasing loss (using the derivative) learning rate (how much we want to move in the error direction, often this will change over time)

  28. Gradient Descent w/ Exponential Loss

  29. Gradient descent • pick a starting point (w) • repeat until loss doesn’t decrease in any dimension: • pick a dimension • move a small amount in that dimension towards decreasing loss (using the derivative)

  30. Exponential update rule for each example xi: Notice the weight update. Does this look familiar?

  31. Perceptron learning algorithm! or where

  32. The “new” constant prediction label learning rate When is this large/small?

  33. The “new” constant prediction label If prediction is correct (same sign), as the prediction gets larger, the update gets smaller If the prediction is incorrect (different sign), the more different they are, the bigger the update

  34. Perceptron learning algorithm! Note: for gradient descent, we always update or where

  35. Recap Model-based machine learning: • define a model, objective function (i.e. loss function), minimization algorithm Gradient descent minimization algorithm • requires that our loss function is convex • make small updates towards lower losses Perceptron learning algorithm: • gradient descent • exponential loss function (modulo a learning rate)

More Related