Skip to content

What is Loss Function?

A loss function quantifies how far a model's predictions are from the true values, serving as the objective that training tries to minimize.

It acts as a numerical score of error for each prediction or batch of predictions. During training, the model adjusts its parameters to drive this score downward.

Common loss functions include mean squared error for regression and cross-entropy for classification. The choice depends on the task and output type.

Loss is typically computed on training data and used by optimizers such as gradient descent to update model weights via backpropagation.

Example

In a model that predicts house prices, the loss might be the average of (predicted price minus actual price) squared across all houses in the training set.

Why it matters

Loss functions are central to modern AI because they turn the abstract goal of 'learning' into a concrete optimization problem that can be solved at scale with gradient-based methods.

Frequently asked questions

No. Loss measures error magnitude while accuracy measures the fraction of correct predictions; a model can have low loss yet imperfect accuracy.