Skip to content
Sign in

What is Gradient?

In machine learning, a gradient is a vector of partial derivatives that shows how a model's error (loss) changes with respect to its parameters. It points toward the steepest increase in error, so optimization algorithms move in the opposite direction to improve the model.

Mathematically, the gradient of a multi-variable function is a vector containing its partial derivatives with respect to each input variable, representing the slope or rate of change in every direction.

In ML, gradients are calculated for the loss function during training; they indicate how small changes to weights and biases affect overall prediction error.

This information drives iterative updates in algorithms like gradient descent, allowing models to learn by gradually reducing errors.

Example

When training a simple linear regression model to predict house prices, the gradient for the weight on 'square footage' might show that increasing the weight reduces error, so the algorithm adjusts that weight accordingly in the next step.

Why it matters

Gradients power the training of nearly all modern neural networks and other ML models via gradient-based optimization, enabling scalable learning from data.

Frequently asked questions

A derivative measures change for a single variable, while a gradient is the vector of derivatives for multiple variables.