Gradient

1 min read

The gradient ∇f\nabla f of a scalar function f:Rn→Rf : \mathbb{R}^n \to \mathbb{R} is the vector of all partial derivatives:

∇f=[∂f∂x1,∂f∂x2,…,∂f∂xn]⊤\nabla f = \left[\frac{\partial f}{\partial x_1}, \frac{\partial f}{\partial x_2}, \dots, \frac{\partial f}{\partial x_n}\right]^\top

Key properties:

  • Points in the direction of steepest ascent of ff
  • Its magnitude ∥∇f∥\|\nabla f\| is the rate of steepest ascent
  • It is perpendicular to level sets (contour surfaces) of ff
  • ∇f=0\nabla f = 0 at critical points (local min, max, or saddle)

Gradient descent walks downhill: xt+1=xt−η∇f(xt)\mathbf{x}_{t+1} = \mathbf{x}_t - \eta \nabla f(\mathbf{x}_t), where η\eta is the learning rate. This is the foundation of all neural network training via Stochastic Gradient Descent.

Numerical gradient (finite differences): ∂f∂xi≈f(x+ϵei)−f(x−ϵei)2ϵ\frac{\partial f}{\partial x_i} \approx \frac{f(x + \epsilon e_i) - f(x - \epsilon e_i)}{2\epsilon}. Useful for gradient checking but O(n)O(n) cost per evaluation.

See also: Chain Rule (Multivariable), Jacobian Matrix, Hessian Matrix

Linked from