Dictionary of Applied Machine Learning
Updated on 2026-09-17
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. 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, it does. 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 drive gradient descent (GD) methods and are computed for deep networks by backpropagation.
B-partialsTraining a machine learning (ML) model adjusts its model parameters
$\weights$ to reduce a loss $f(\weights)$, which requires knowing
how $f$ changes as $\weights$ moves. The gradient of a
real-valued function
$f: \reals^{\featuredim} \rightarrow \reals: \weights \mapsto f(\weights)$
answers this by determining 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
\begin{equation}\label{eq_gradient_def}
\lim_{\weights \rightarrow \weights'}
\frac{f(\weights) - \big( f(\weights') + \vg^{\top} (\weights - \weights') \big)}{\normgeneric{\weights - \weights'}{2}}
= 0 \text{.}
\end{equation}
If such a vector exists, it is unique, the function $f$ is
differentiable at $\weights'$, and the vector is 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).
B-hilbertThe definition carries over to a real-valued function $f: \hilbertspace \rightarrow \reals$ on a real Hilbert space $\hilbertspace$ (a Hilbert space over $\reals$; the complex case needs a separate treatment of the sesquilinear inner product): the inner product $\innerprod{\vg}{\weights - \weights'}$ of $\hilbertspace$ replaces the term $\vg^{\top} (\weights - \weights')$ in the defining limit \(\eqref{eq_gradient_def}\), and the norm of $\hilbertspace$ replaces the Euclidean norm $\normgeneric{\weights - \weights'}{2}$ (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 —
the set $\{\weights : f(\weights) = c\}$ of points where $f$ takes a
common value $c$ — and it points in the direction of steepest ascent of
$f$. The negative gradient $-\nabla f(\weights')$ 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). 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},
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-09-21},
url = {https://dictionaryofml.org/terms/gradient.html}
}