1
$\begingroup$

I am trying to understand how gradient descent works. My understanding is that the update rule works as follows: $$ x_{n+1} = x_n - \alpha f'(x_n) $$ This seems magical to me.

  1. How did this update rule come about?
  2. How do I know $x_{n+1}$ lies on $f(x)$?

A simple explanation will be appreciated. Simple proof and/or pictorial description would be nice too!

$\endgroup$
2
$\begingroup$

One important property of the gradient of a function is that it points in the direction where the function increases most if you take an infinitely small step. Conversely, it decreases most in the exact opposite of the direction. Thus, moving a small step in that direction will increase $f$.

It is best to work through this with an example to see that it works. Say we want to minimize $f(x) = x^2$. The minimum is at $x = 0$ and we start our optimization at $x_0 = 2$. The derivative is given by $f'(x) = 2x$. Thus, the gradient at our starting position is $f'(x_0) = 4$. Moving into the opposite direction of that gradient (since we are minimizing) brings us towards 0.

Of course, there are issues: Finding a good step rate (your $\alpha$) is crucial, since you might overshoot. Also, gradient descent might take very long in high dimensions. This is why optimization is still a very active and important branch of mathematics.

Regarding your second question: gradient descent assumes that all $x$ are in the domain of $f$.

You might find further guidance on math.stackexchange.com.

$\endgroup$
  • $\begingroup$ Thank you for your answer. But how do I know that $x_{n+1}$ lies on $f(x)$, as I decrease $x_n$ by a certain value? Is that simply an assumption?? $\endgroup$ – Jimmy Nov 12 '12 at 21:26
  • $\begingroup$ $x_{n+1}$ isn't on $f(x)$, it's the input to $f(x)$. $f(x_{n+1})$ is on $f(x)$. $\endgroup$ – assumednormal Nov 12 '12 at 21:31
  • $\begingroup$ @Max Maybe I am missing something. If $x_{n+1}$ is not on $f(x)$, how are we able to evaluate the function at that point? $\endgroup$ – Jimmy Nov 12 '12 at 22:14
  • $\begingroup$ I think the poster's question has to do with the dynamical system aspect of it. If $f(x_n)$ takes $x_{n+1}$ to a boundary of the system's compact domain, then what happens since $f'(x_{n+1})$ is singular? This is an issue with any iterative solver, though, and is more than just a matter of supplying better starting values. Statisticians often look to a change of variable to ensure that $x$ has a sane domain, such as GLMs and Newton-Raphson where the model is linear and regular on the log odds scale rather than irregular on the probability scale. $\endgroup$ – AdamO Nov 12 '12 at 22:16
  • $\begingroup$ Can you explain more of what nature $f(x)$ exactly is? In most optimization problems, $f: \mathbb{R}^n \rightarrow \mathbb{R}$, so going along the gradient always keeps you in the domain. $\endgroup$ – bayerj Nov 13 '12 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.