Dictionary of Applied Machine Learning: 114 machine-learning terms, each with a definition, a figure, citations and a Python demo · All terms · Demos · Start here
Updated on 2026-11-04
Readiness 100/100
See also gradient descent convex Hilbert space
The gradient of a real-valued function is a vector that determines the local linear approximation of the function. The entries of the gradient are the partial derivatives of the function. Their existence does not by itself make the function differentiable: the vector they form need not give a local linear approximation. For a convex function, the existence of all partial derivatives at a point already makes it differentiable there. Geometrically, a nonzero gradient is orthogonal to the level sets and points in the direction of steepest ascent. In machine learning (ML), gradients of the empirical risk minimization (ERM) objective function define the update of gradient descent (GD) methods and are computed for deep networks by backpropagation.

gradient.py, which recomputes what the entry states: the script block by block · open in ColabB-partialsA linear model for the maximum temperature at Krems an
der Donau has two model parameters, and changing either of them changes
the average squared error loss on the training set. Training a
machine learning (ML) model adjusts its model parameters ${\mathbf w}$ to reduce
a loss $f({\mathbf w})$, which requires knowing how $f$ changes as
${\mathbf w}$ moves. The gradient of a
real-valued function
$f: \mathbb{R}^{d} \rightarrow \mathbb{R}: {\mathbf w} \mapsto f({\mathbf w})$
answers this by determining a local linear approximation of $f$. Formally, the gradient
of $f$ at a point ${\mathbf w}' \in \mathbb{R}^{d}$ is a vector
${\mathbf g} \in \mathbb{R}^{d}$ such that
\begin{equation}\label{eq_gradient_def}
\lim_{{\mathbf w} \rightarrow {\mathbf w}'}
\frac{f({\mathbf w}) - \big( f({\mathbf w}') + {\mathbf g}^{\top} ({\mathbf w} - {\mathbf w}') \big)}{\left\lVert {\mathbf w} - {\mathbf w}' \right\rVert_{2}}
= 0 \text{.}
\end{equation}
If such a vector exists, it is unique, the function $f$ is
differentiable at ${\mathbf w}'$, and the vector is denoted by
$\nabla f({\mathbf w}')$ or $\nabla f({\mathbf w}) \big|_{{\mathbf w}'}$
(Rudin, 1976, Def. 9.11 and Thm. 9.12). The function
$f({\mathbf w}') + \big(\nabla f({\mathbf w}')\big)^{\top} ({\mathbf w} - {\mathbf w}')$
is the local linear approximation of $f$ at ${\mathbf w}'$
(see Fig. 1).
B-backpropAt every point where
$f$ is differentiable and $\nabla f \neq \mathbf{0}$, the gradient is
orthogonal to the level set of $f$ through that point, the set
$\{{\mathbf w} : f({\mathbf w}) = c\}$ of points where $f$ takes a
common value $c$. It also points in the direction of steepest ascent of
$f$. The negative gradient $-\nabla f({\mathbf w}')$ points in the direction of
steepest descent, and gradient descent (GD) repeatedly steps along it (see
Fig. 2; Boyd and Vandenberghe, 2004, Sect. 9.4.1). At a local minimum of a
differentiable function $f: \mathbb{R}^{d} \rightarrow \mathbb{R}$,
there cannot be any direction of descent and consequently the gradient
must vanish (see zero-gradient condition).
pythondemos/gradient.py
The definition carries over to a real-valued function $f: \mathcal{H} \rightarrow \mathbb{R}$ on a real Hilbert space $\mathcal{H}$, a Hilbert space over $\mathbb{R}$. In the defining limit \(\eqref{eq_gradient_def}\), the inner product $\langle {\mathbf g}, {\mathbf w} - {\mathbf w}' \rangle$ of $\mathcal{H}$ replaces the term ${\mathbf g}^{\top} ({\mathbf w} - {\mathbf w}')$. The norm of $\mathcal{H}$ replaces the Euclidean norm $\left\lVert {\mathbf w} - {\mathbf w}' \right\rVert_{2}$ (Bauschke and Combettes, 2011, Remark 2.44 and Def. 2.45).
See also: function, vector, differentiable, partial derivative, gradient descent, zero-gradient condition, convex, Hilbert space.
@misc{dictml_gradient,
author = {Jung, Alexander},
editor = {Olioumtsevits, Konstantina and Schnoor, Ekkehard},
title = {gradient},
howpublished = {Dictionary of Applied Machine Learning (course edition)},
year = {2026},
doi = {10.5281/zenodo.21569296},
note = {ISBN 978-952-64-3013-3, CC BY 4.0, retrieved 2026-11-04},
url = {https://dictionaryofml.org/terms/gradient.html}
}