Dictionary of Applied Machine Learning
Typeset PDF version — the authoritative form of this entry
Python demo — a script that recomputes what this entry states and prints one line per check
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. However, the existence of partial derivatives does not imply the existence of a gradient, unless the function is convex. 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 drive gradient descent (GD) methods and are computed for deep networks by backpropagation.
B-partialsThe gradient of a real-valued function
$f: \reals^{\featuredim} \rightarrow \reals: \weights \mapsto f(\weights)$
determines a local linear approximation of $f$. Formally, the gradient
of $f$ at a point $\weights' \in \reals^{\featuredim}$ is a vector
$\vg \in \reals^{\featuredim}$ such that
\[
\lim_{\weights \rightarrow \weights'}
\frac{f(\weights) - \big( f(\weights') + \vg^{\top} (\weights - \weights') \big)}{\normgeneric{\weights - \weights'}{2}}
= 0 \text{.}
\]
If such a vector exists, it is unique and denoted by
$\nabla f(\weights')$ or $\nabla f(\weights) \big|_{\weights'}$
(Rudin, 1976, Ch. 9). The function
$f(\weights') + \big(\nabla f(\weights')\big)^{\top} (\weights - \weights')$
is the local linear approximation of $f$ at $\weights'$
(see Fig. 1). The entries of
the gradient are the partial derivatives of $f$,
$\nabla f(\weights) = \big( {\partial f}/{\partial \weight_{1}}, \ldots, {\partial f}/{\partial \weight_{\featuredim}} \big)^{\top}$.
B-hilbertThe definition carries over to a real-valued function $f: \hilbertspace \rightarrow \reals$ on a Hilbert space $\hilbertspace$: the inner product $\innerprod{\vg}{\weights - \weights'}$ of $\hilbertspace$ replaces the term $\vg^{\top} (\weights - \weights')$, and the norm of $\hilbertspace$ replaces the Euclidean norm (Bauschke and Combettes, 2011).
B-backpropThe gradient has a geometric interpretation. At 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, and it points in the direction of steepest
ascent of $f$. The negative gradient $-\nabla f(\weights')$ points in
the direction of steepest descent (see Fig. 2;
Boyd and Vandenberghe, 2004, Sect. 9.4). At a local minimum of a
differentiable function $f: \reals^{\featuredim} \rightarrow \reals$,
there cannot be any direction of descent and consequently the gradient
must vanish (see zero-gradient condition).
pythondemos/gradient.py
See also: function, vector, differentiable, partial derivative, gradient descent, zero-gradient condition, convex, Hilbert space.
@misc{dictml_gradient,
author = {Jung, Alexander},
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-08-21},
url = {https://dictionaryofml.org/terms/gradient.html}
}