6 ms·
Understanding gradient descent
- jordigh 10y agoI need to write something about conjugate gradients. The first thing we did in my optimisation class at CIMAT was gradient descent and showed how it was so slow compared to everything else. In practical applications, there's way too much magic in choosing the so-called "learning rate" (known as "step size" in numerical optimisation). Even choosing an optimal step size per iteration (by doing a line search), gradient descent is still slow. Conjugate gradients are a bit more difficult to understand, but they're not that hard to implement if you just blindly copy a few formulae, and they are a dramatic speedup. All of these blog posts about gradient descent feel like everyone keeps going on about what a great algorithm bubblesort is because it's so easy to understand and implement.
- dharmon 10y agoThis was the "standard" text we used for new grad students to understand CG. It's not perfect but covers the ideas and algorithms pretty well: http://www.cs.cmu.edu/%7Equake-papers/painless-conjugate-gradient.pdf http://www.cs.cmu.edu/%7Equake-papers/painless-conjugate-gra...
- eliben 10y agoClaiming that gradient descent is a great algorithm certainly wasn't the goal of this article. But GD is the basis from which most other iterative algorithms stem, and it's worthwhile having a good understanding of its inner workings as a prerequisite for more advanced algorithms. Personally I found http://sebastianruder.com/optimizing-gradient-descent/ http://sebastianruder.com/optimizing-gradient-descent/ interesting - it goes into the advanced variants like nesterov, adadelta, etc
- jordigh 10y agoI realise, but since a lot more gets written about steepest descent than everything else, it also gets implemented and used a lot more often, even when other alternatives are readily available and already implemented. For example, the trainscg method of Matlab is relatively obscure thus unused and not frequently re-implemented. There's an implicit endorsement in these blog posts. People wouldn't be spilling all this ink nowadays on plain adalines, even if they're building blocks for backprop networks, right? So by writing so much about it, people get the impression that it has to be studied and implemented very carefully, to the exclusion of better methods.
- maxerize 10y agoAs the above poster said, if you can introduce people to a topic by explaining a simplified or 'naive' solution/algorithm, then that could be a good springboard to learn more about the topic. Which is why there should be more comments presenting improvements and alternatives, rather than criticising what is obviously meant as a primer on optimisation. From the intro: Gradient descent is a standard tool for optimizing complex functions iteratively within a computer program. Its goal is: given some arbitrary function, find a minima. For some small subset of functions - those that are convex - there's just a single minima which also happens to be global. For most realistic functions, there may be many minima, so most minima are local. Making sure the optimization finds the "best" minima and doesn't get stuck in sub-optimial minima is out of the scope of this article. Here we'll just be dealing with the core gradient descent algorithm for finding some minima from a given starting point.
- theoh 10y agoThe way the author uses the word "minima" as if it was both singular and plural is a really discouraging sign.
- theoh 10y agoPresumably you are aware of Jonathan Shewchuk's "An Introduction to the Conjugate Gradient Method Without the Agonizing Pain": https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf https://www.cs.cmu.edu/~quake-papers/painless-conjugate-grad...
- nkurz 10y agoIlya Kuzovkin did nice companion article in the form of a Python Notebook to accompany Shewchuk's classic: "The Concept of Conjugate Gradient Descent in Python" http://ikuz.eu/2015/04/15/the-concept-of-conjugate-gradient-descent-in-python/ http://ikuz.eu/2015/04/15/the-concept-of-conjugate-gradient-... And for those with more math and less patience for explanation, Robert Gower also offers: "Conjugate Gradients: The short and painful explanation with oblique projections" http://www.maths.ed.ac.uk/~s1065527/pdf/GowerR_Painful_PCG_projections http://www.maths.ed.ac.uk/~s1065527/pdf/GowerR_Painful_PCG_p...
- pmarreck 10y agoIf only there was a faster known way to get the inverse of a matrix... Gradient descent seems like an ugly hack compared to that (having taken an ML class) It reminds me of taking the derivative by manually measuring the slope between 2 points on the curve, instead of, you know, directly getting the derivative
- jofer 10y agoGradient descent is for non-linear problems where you can't directly invert or somehow linearize the problem.
- pmarreck 10y agoOften you can directly invert, but with current methods it would just be prohibitively expensive computationally. What I'm trying to say is that occam's razor seems to suggest that there is a better way to do matrix inversions which we simply haven't discovered yet.
- dragonwriter 10y ago> What I'm trying to say is that occam's razor seems to suggest that there is a better way to do matrix inversions which we simply haven't discovered yet. Occam's razor doesn't suggest that. Such a method is an additional assumed entity that adds nothing to our ability to explain what is observed, and is thus the kind of thing Occam's razor calls one to reject, rather than suggests. Now, belief in the existence of such a method might be a means of satisfying an aesthetic preference for a computationally convenient universe, but that's something very different than Occam's razor.
- pmarreck 10y agoFair enough, you got at what I was getting at in your last paragraph
- xaedes 10y agoTaking the inverse of a matrix only solves problems which can be described in a specific way. There are situations where you want to optimize an arbitrary function. Also taking the inverse of a matrix isn't always easy. For example for very large matrices. The are also problems where the optimal solution changes over time (e.g. trajectory following control). This gives a good guess for the solution at each timestep(t>0) and improving that with gradient descent can be more performant than completely solving for a matrix inverse each time.
- gulpahum 10y agoWhat about minimum of a non-differentiable function? I've been using something like Nelder–Mead method (downhill simplex method / amoeba method) [1], but it gets slow near the minimum. [1] https://en.wikipedia.org/wiki/Nelder–Mead_method https://en.wikipedia.org/wiki/Nelder–Mead_method
- chestervonwinch 10y agoI've always thought that this was a fun way to look at it: Suppose you solve the differential equation, x'(t) = -f'(x(t)) (1) Then, d/dt f(x(t)) = f'(x) x'(t) = - [f'(x)]^2 <= 0 In other words, if `x(t)` follows a path that solves (1), then `x(t)` follows a path that decreases the value of `f(x)`. The gradient descent algorithm is a numerical approximation to solving (1) using the forward Euler method: (x(t_(n+1)) - x(t_n)) / dt = -f'(x(t_n))
- RBerenguel 10y agoNice and clear way to think about it (and touching closer to the kind of numerical analysis I drilled most, too). I wonder, if having a good polynomial description of f then we can "just" use a Taylor integration method, approximating the inverses needed along the way with some high order approximation.
- dxbydt 10y agoPerhaps an example might help. Say x(t) = exp(-t) f(x(t)) = (x^2)/2 Then it satisfies conditions imposed by parent, namely x' = -x = -f'
- chestervonwinch 10y agoNice. I think you mean f(x) = 0.5*x^2 though.
- Chris2048 10y agoIs it not: d/dt f(x(t)) = f'(x(t)) x'(t) = -(-f'(x(t))) x'(t) = -(x'(t)) x'(t) = -[x'(t)]^2 = -[f'(x(t))]^2 ?