# Loss Function

- **Canonical URL:** https://getaimath.com/dictionary/loss-function/
- **Topics:** [AI & Machine Learning Fundamentals](https://getaimath.com/dictionary/category/ai-and-machine-learning-fundamentals/)
- **Last updated:** 2026-11-25

## What is Loss Function?

**In one sentence:** A loss function is a formula that measures how wrong a model's answer is, giving one number to make smaller.

After the model guesses, the loss function compares the guess with the right answer and gives a score: big when the guess is far off, small when it is close. Training is all about pushing that number down. It works like a "you're getting warmer or colder" game for the model.

![Training vs. Inference: Studying Flashcards vs. Taking the Test — Simple cartoon diagram comparing AI Training (studying 1,000 flashcards and fixing mistakes until the brain learns the pattern) with AI Inference (answering a brand-new question in 1 second on test day).](https://getaimath.com/diagrams/ai-and-machine-learning-fundamentals.png)
*Napkin Diagram (AI & Machine Learning Fundamentals): Training is the long study session where the AI learns from examples; inference is test day when you actually use it.*

## What is an example of Loss Function?

If a model guesses a house costs $200,000 but it really costs $300,000, the loss function turns that gap into a "wrongness" score.

## Why does Loss Function matter?

The loss function tells the model what "better" means, so choosing it carefully shapes the whole model.

## Related Concepts

- [Label](https://getaimath.com/dictionary/label/): A label is the correct answer attached to an example in a training dataset.
- [Optimization](https://getaimath.com/dictionary/optimization/): Optimization is the process of adjusting a model's numbers step by step to make its mistakes as small as possible.
- [Feature](https://getaimath.com/dictionary/feature/): A feature is one piece of information about an example that a model uses to make a decision.
- [Gradient Descent](https://getaimath.com/dictionary/gradient-descent/): Gradient descent is a method for training models by repeatedly taking small steps in the direction that reduces mistakes the most.
- [Ground Truth](https://getaimath.com/dictionary/ground-truth/): Ground truth is the real, correct answer that a model's guesses are compared against.
- [Backpropagation](https://getaimath.com/dictionary/backpropagation/): Backpropagation is the method a neural network uses to figure out which of its numbers caused a mistake, so it can fix them.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/loss-function/)
