A loss function, also called a cost or objective function, converts the gap between a model's predictions and the true targets into one number. Training adjusts the parameters to make that number as small as possible, usually with gradient descent.
Why it matters
The loss defines what the model is actually optimising, so choosing it well matters. Mean squared error is common for regression and penalises large errors heavily. Cross-entropy is standard for classification and language models, and it punishes confident wrong answers. A loss must be differentiable for gradient-based training, which is why it is often not the same as the business metric you care about, such as accuracy or revenue.
Example
Mean squared error, true = [3, 5], predicted = [2, 8]
errors = [-1, 3]
squared = [1, 9]
MSE = (1 + 9) / 2 = 5
A better model would give a lower value than 5 on the same data.
Common mistakes
- Optimising a loss that does not match the real goal, then being surprised by results.
- Reading a falling training loss as success without checking validation loss.
- Comparing loss values across different loss functions or datasets.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.