Gradient descent: Difference between revisions
Created page with "Category:Optimisation algorithm Category:Artificial neural network '''Gradient descent''' is an iterative optimisation algorithm used to find the local minimum of a differentiable function. It is the fundamental algorithm used to train many machine learning models, including artificial neural network (ANN). == Mathematical definition == === Goal === Let $f(\vec x)$ be a differentiable function. Gradient descent finds a value of $\vec x_n$ s..." |
No edit summary |
||
| Line 40: | Line 40: | ||
{{Hidden example}} | {{Hidden example}} | ||
[[File:Gradient descent intuition.png|thumbnail|$-\nabla f$ is always the direction of the steepest descent.]] | |||
Find $(x,y)$ that minimises | Find $(x,y)$ that minimises | ||
$$ | $$ | ||
C(x,y)=x^2+2y^2+3x-4y+6. | |||
$$ | $$ | ||
| Line 51: | Line 52: | ||
$$ | $$ | ||
\nabla | \nabla C(x,y)= | ||
\begin{pmatrix} | \begin{pmatrix} | ||
2x+3\\ | 2x+3\\ | ||
| Line 70: | Line 71: | ||
$$ | $$ | ||
\nabla | \nabla C(0,0)= | ||
\begin{pmatrix} | \begin{pmatrix} | ||
3\\ | 3\\ | ||
| Line 91: | Line 92: | ||
{| class="wikitable" | {| class="wikitable" | ||
! $n$ !! $x_t$ !! $y_t$ !! $\frac{\partial | ! $n$ !! $x_t$ !! $y_t$ !! $\frac{\partial C}{\partial x}(x_t,y_t)$ !! $\frac{\partial C}{\partial y}(x_t,y_t)$ | ||
|- | |- | ||
| 0 || 0 || 0 || 3 || -4 | | 0 || 0 || 0 || 3 || -4 | ||
| Line 153: | Line 154: | ||
=== Training [[artificial neural network (ANN)]] === | === Training [[artificial neural network (ANN)]] === | ||
[[File:Trashyard Machine learning.png|thumbnail|In some sense, [[ANN]] training is like stirring up a pile of trash: improvement is made by stirring up the weight&biases matrix ever so slightly according to current gradient, recalculate the new prediction values and new gradient, and stirring up the pile again, so on so forth until finding a $\mathbf{W}_n$ s.t. $C(\mathbf{W}_n)<C_\text{target}$.]] | |||
Let $\mathbf{W}$ be the '''weight&biases matrix''' of an [[artificial neural network (ANN)]], $C(\mathbf{W})$ its '''cost function''', which measures the error between the model's predictions and the true values in the training set (e.g., [[sum of squared errors (SSE)]]). | Let $\mathbf{W}$ be the '''weight&biases matrix''' of an [[artificial neural network (ANN)]], $C(\mathbf{W})$ its '''cost function''', which measures the error between the model's predictions and the true values in the training set (e.g., [[sum of squared errors (SSE)]]). | ||
Revision as of 13:21, 10 November 2026
Gradient descent is an iterative optimisation algorithm used to find the local minimum of a differentiable function.
It is the fundamental algorithm used to train many machine learning models, including artificial neural network (ANN).
Mathematical definition
Goal
Let $f(\vec x)$ be a differentiable function.
Gradient descent finds a value of $\vec x_n$ s.t $f_\text{min}=f(\vec x_n)$.
Process
Start with a reasonable guess $\vec x_0$ and iteratively updates according to the rule:
$$ \vec x_{t+1} = \vec x_t - \eta \nabla f(\vec x_t) $$
until $\nabla f(\vec x_n) \to \vec 0$, then $\vec x=\vec x_n$ is a local minimum of $f$.
where:
- $\vec x_t$ is the value of the $t^\text{th}$ iteration.
- $\eta \in (0,1)$ is the learning rate
- $\nabla f(\vec x_t)$ is the gradient of the function at $\vec x_t$.
Why $-\nabla f$: The gradient $\nabla f$ points in the direction of the steepest ascent. To minimise the function, move in the opposite direction for the steepest descent.
Gradient descent is most useful for complex functions. For simple functions setting directly $\eta \nabla f(\vec x)=0$ and solve for $\vec x$ finds local extremum candidates. Evaluate $f$ at all candidate points and take the lowest value to obtain the global minimum of $f$, which is simpler and more accurate.
Mathematical example
Applications
Training artificial neural network (ANN)

Let $\mathbf{W}$ be the weight&biases matrix of an artificial neural network (ANN), $C(\mathbf{W})$ its cost function, which measures the error between the model's predictions and the true values in the training set (e.g., sum of squared errors (SSE)).
Then training is iteration with step $$ \mathbf{W}_{t+1} = \mathbf{W}_t - \eta \nabla C(\mathbf{W}_t). $$
