ATLAS NOVA My AtlasVelocer ↗

Concept · Machine learning

Loss function

Machine learning loss function

A loss function is a rule that assigns a number to a prediction, saying how far that prediction is from what was wanted.

The number is called the loss, and smaller is better. The rule takes at least two things as input: the value the model produced and the target it should have produced. It then returns a penalty that grows as the two drift apart. A model that guesses a person's weight at 70 kilograms when the true weight is 75 pays some penalty; a guess of 90 pays a larger one. The same logic applies to a label attached to a single pixel in a medical scan, where the prediction is a probability and the target is whether that pixel belongs to a tumour or to background.

Key facts
97.2Accuracy reached by a 15-layer CNN with Focal loss on lung nodules (Tran et al., 2019)⁠[1]
76.39Accuracy of the CNN-LSTM lung sound model with Focal loss (Petmezas et al., 2022)⁠[2]
45.0Average precision of Generalized Focal loss on COCO test-dev (Li et al., 2020)⁠[3]
0.7Typical weight assigned to false negatives in the Tversky loss (Yeung et al., 2022)⁠[4]

Overview

Loss function

Training a model means adjusting its internal settings so that the average loss over many examples becomes as small as it can. The loss is therefore not a report card written after the fact. It is the quantity the learning procedure actually pushes down, step by step, and the model ends up shaped by whatever the loss rewards. In deep networks, backpropagation updates model parameters in accordance with the optimisation goal defined by the loss function. Because the loss defines the optimisation problem, its choice has direct consequences for whether training converges and what kind of errors the finished model makes.⁠[4]

A numbered training loop connects inputs, a neural network, target comparison, average loss, backpropagation and gradient descent beside a squared-error curve.
Predictions and targets determine an average loss whose gradient guides parameter updates. A squared-error example shows how a closer prediction lowers the loss. View full-size image.How Loss Drives Model Training by Atlas Nova. Illustration generated with AI for this article and checked against its text.

Different tasks call for different rules. A task that predicts a quantity, such as a weight or a pixel brightness, needs a penalty that measures distance on a number line. A task that sorts examples into categories needs a penalty that compares probability distributions, and the cross entropy loss is typically the most widely used loss function in classification problems.⁠[4] Image restoration, by contrast, has treated the squared error as the default and virtually only choice, with the loss layer receiving little attention.⁠[5] A broad survey of the field now treats the pairing of a loss with a matching evaluation metric as a central design decision, one that has to be made separately for regression, classification, vision and language tasks.⁠[6]

Two difficulties recur across those settings. The first is class imbalance, an unequal distribution of examples among the categories, so that one class vastly outnumbers another. In medical imaging a lesion often occupies a small fraction of the image, and a loss that counts every pixel equally will be dominated by the healthy background and can return poor segmentation of the small structure that matters.⁠[4] The second is label noise, where some training targets are simply wrong. A loss that trusts every label completely will fit the mistakes along with the signal, and the choice of penalty determines how much damage those mistakes do.

A loss is thus best understood as a stand-in for the outcome actually wanted. It has to be computable and smooth enough for the training procedure to follow, which means it is rarely identical to the real goal, such as a correct diagnosis or a pleasing image. The sections that follow take up where the idea came from, how a loss is built from its parts, the main families of loss in use, and the evidence that changing the loss alone can change results.

A loss function turns "how wrong was that?" into a number the model can minimise, and the choice of that number's rule shapes everything the model learns.

History

From scheduling deadlines to training neural networks

The word "loss" entered the technical vocabulary well before computers learned anything. In operations research it named a cost incurred by finishing a job late: a set of one-stage tasks had to be scheduled on several processors of differing efficiency, each task carried a deadline, and the loss attached to a task was a function of how far past its deadline it was completed, and zero if it finished on time.⁠[7] The total loss summed these individual penalties, and the scheduling problem was to arrange the work so that the sum came out as small as possible. The shape of the idea is already visible here: a number that measures the badness of an outcome, built up from the badness of its parts, and a procedure that searches for the arrangement that makes the number small.

Statistical learning theory later asked a sharper question about such numbers. If a learning method is judged by how well it generalises to new data, does the particular loss used to fit it matter, or do all reasonable losses lead to about the same place? The answer turned out to depend on the loss. Under a convexity assumption satisfied by the losses in common use, the bound on estimation error changes with the loss, and for classification the hinge loss emerged as the loss of choice: other things being equal, it gave a convergence rate practically indistinguishable from the logistic loss and much better than the square loss, and with a sufficiently rich hypothesis space its bounds were not loosened by the thresholding step that turns a score into a class decision.⁠[8] The choice of penalty was not cosmetic. It changed how fast learning converged and how tightly the error could be bounded.

Yet practice lagged behind the theory in at least one corner. In image restoration, the loss layer drew little attention, and the default and virtually only choice was the squared error, ℓ2.⁠[5] That default is a specific assumption about what counts as a bad prediction: it penalises an error of two units four times as heavily as an error of one, and it treats a few large mistakes as far worse than many small ones. Whether that matches what a human observer cares about in a restored photograph is a separate question, and one that the field had not been asking.

The modern picture, then, is a line running from a deadline penalty in a scheduling problem, through a proof that the penalty's shape governs how well a classifier generalises, to a layer in a neural network whose output the optimiser drives down. What connects the three is the same move: replace a vague wish for a good outcome with a number that can be computed and minimised, then let a procedure do the minimising. The rest of the subject is largely about choosing that number well.

Main ideas

The parts of a loss: prediction, target, and penalty

Every loss function is built from the same three ingredients, and seeing them separately makes the rest of the subject much easier to follow. The first is the prediction, the value the model actually produced: a number, a probability, or a label for each pixel. The second is the target, also called the ground-truth label, the value the model should have produced. The third is the penalty rule, the arithmetic that combines the two into a single number. Change any one of the three and the loss changes, but the penalty rule is where the real design decisions live, because the prediction and the target are usually fixed by the task.

The penalty rule has to answer a deceptively simple question: given a prediction and a target, how bad is the gap between them? Different answers suit different kinds of target. When the target is a quantity on a number line, such as a weight, a temperature, or the brightness of a pixel, the task is called regression, and the penalty is a measure of distance. The most common choice squares the difference before adding it up, which makes the penalty grow steeply with large errors and gently with small ones. When the target is a category, such as tumour or background, the task is classification, and the prediction is usually a probability for each category rather than a single number.

The penalty then has to compare two probability distributions, one predicted and one true, and the standard tool for that comparison is cross entropy, which measures the difference between two probability distributions for a given random variable or set of events. Cross entropy has its origins in information theory, and as a loss it is superficially equivalent to the negative log likelihood.⁠[4] The details of how it is computed, and why it behaves badly when one class vastly outnumbers another, are taken up later.

A useful way to organise the many penalty rules is by what part of the prediction they look at. In image segmentation, where every pixel receives a label, loss functions fall into four broad groups: distribution-based losses such as cross entropy, region-based losses such as the Dice loss, boundary-based losses such as the boundary loss, and compound losses that combine several independent loss functions into one.⁠[4] The grouping is not arbitrary. A distribution-based loss judges each pixel's predicted probability against its label and then averages, so it is sensitive to how many pixels of each kind are present. A region-based loss compares whole regions, asking how much the predicted object and the true object overlap, which makes it less swayed by the sheer count of background pixels. A boundary-based loss concentrates on the outline, where a segmentation either traces the edge of a structure correctly or does not. A compound loss adds two or more of these together, on the reasoning that each catches errors the others miss.

The choice between these families is not a matter of taste alone. A comparison of seven loss functions on the CVC-EndoSceneStill dataset of gastrointestinal polyp images found the best performance with region-based losses and the worst with cross entropy, and a separate comparison of fifteen loss functions on the NBFS Skull-stripped brain CT segmentation dataset concluded that Focal Tversky loss and Tversky loss, both region-based losses, are generally optimal. A larger comparison of twenty loss functions across four datasets, covering liver, liver tumour, pancreas and multi-organ segmentation, found the best performance with compound losses, with the most consistent results from two combinations of Dice and focal terms.⁠[4] What these comparisons share is a lesson about the third ingredient: the penalty rule decides which mistakes the model is pushed hardest to avoid, and different rules push in different directions.

That last point deserves emphasis because it is easy to miss. A loss does not merely score a model after the fact; it defines what counts as a mistake worth fixing. A rule that squares the error treats one large miss as far worse than several small ones, so the model will work hardest to eliminate the large miss and may tolerate a scatter of small ones. A rule that counts misclassified pixels equally treats every pixel as equally important, so a model trained on an image that is mostly background will do well by predicting background everywhere. Neither rule is wrong in the abstract. Each encodes an assumption about which errors matter, and the assumption should match the task.

The three ingredients also clarify what it means to design a loss. The prediction is fixed by the network's output, and the target is fixed by the data, so the only free part is the penalty rule, and designing a loss means choosing how to combine the two. That is why the literature on loss functions is largely a literature on penalty rules: squared error, cross entropy, Dice, Tversky, focal, and their combinations are all different answers to the same question about how to price a gap between what was predicted and what was wanted. The sections that follow take up the main families in turn, beginning with cross entropy and its relatives.

Prediction, target, penalty: the first two are given by the task, and the third is the design choice that shapes what the model learns to care about.

The three ingredients that every loss function is built from, with the penalty rule being the design choice.

Cross entropy and its relatives

Cross entropy is typically the most widely used loss function in classification problems.⁠[4] A classifier does not usually output a hard label; it outputs a probability for each category, and the target is a distribution that puts all the weight on the correct category. Cross entropy measures the difference between those two distributions for a given random variable or set of events, and as a loss it is superficially equivalent to the negative log likelihood.⁠[4]

The rule comes in two forms that differ only in how many categories are in play. In binary cross entropy, each example belongs to one of two classes, and the loss is computed from a single predicted probability and its label. In categorical cross entropy, the problem has more than two classes, the ground-truth labels are encoded so that exactly one entry is 1 and the rest are 0, and the predicted values form a matrix with one probability per class per example.⁠[4]

Why counting every pixel equally goes wrong

Averaging treats every pixel as equally important, which is fine when the classes are balanced and quietly disastrous when they are not. In a medical scan a lesion often occupies a small fraction of the image, so the background supplies the overwhelming majority of the pixels in the average. The mechanism is straightforward: cross entropy is based on minimising pixel-wise error, and in class-imbalanced situations this leads to over-representation of larger objects in the loss, which results in poorer-quality segmentation of smaller objects.⁠[4] The loss is doing exactly what it was told; the instruction was simply the wrong one for the task.

The fix that gives this section its name is to stop counting every example equally and start weighting the ones the model finds hard. The Focal loss is a variant of the binary cross entropy loss that addresses class imbalance by down-weighting the contribution of easy examples, which enables learning of harder examples.⁠[4] It does this with two parameters: one controls the class weights, and the other controls the degree of down-weighting of easy-to-classify pixels. When the down-weighting parameter is set to zero, the Focal loss simplifies back to ordinary binary cross entropy.⁠[4] That last property is worth pausing on, because it shows the relationship between the two rules: Focal is not a rival to cross entropy but a modulation of it, a dial that can be turned from "treat everything equally" toward "concentrate on what is still being got wrong."

The idea behind the dial is that down-weighting easy-to-classify pixels enables learning of harder examples. The Focal loss is parameterised by α and γ, which control the class weights and degree of down-weighting of easy-to-classify pixels, respectively.⁠[4]

What the theory says about the family

Cross entropy is not a lone rule but a member of a larger family, and recent theory has begun to say what guarantees the family carries. A broad class called comp-sum losses includes cross entropy, or logistic loss, generalized cross entropy, the mean absolute error and other cross-entropy-like functions, and for these the analysis gives consistency bounds: non-asymptotic guarantees that upper bound the zero-one loss estimation error in terms of the estimation error of the surrogate loss, for the specific hypothesis set in use.⁠[9] In plain terms, a bound of this kind says how much worse the classifier's actual mistake rate can be than the loss value suggests, which is the question a practitioner implicitly asks when trusting a training curve. The same analysis shows the bounds are tight, and it depends on quantities called minimizability gaps, which are analysed specifically for comp-sum losses.⁠[9]

The Focal modulation, the class weighting, and the compound losses covered later are all attempts to keep that argument's benefit while changing which examples the average is built from. The next section takes up the overlap-based losses, which attack the imbalance problem from a different direction entirely, by comparing whole regions rather than summing per-pixel penalties.

Cross entropy prices a confident mistake steeply and averages over everything equally; Focal keeps the pricing but stops the easy majority from drowning out the hard cases.

Overlap losses and the imbalance problem

The per-pixel average at the heart of cross entropy has a natural rival: instead of scoring each pixel and adding up, compare the predicted region as a whole with the true region and ask how much they overlap. The standard measure for that comparison is the Dice similarity coefficient, the most commonly used metric for evaluating segmentation accuracy, defined from the counts of true positives, false positives and false negatives in the per-pixel classification.⁠[4] Because the coefficient is built from the overlap of two regions rather than from a sum over all pixels, the vast background contributes only through its false positives, and the small structure of interest is no longer drowned out by sheer count.

Two overlapping colored circles labeled FP, TP and FN sit between numbered Dice and Tversky calculation panels.
Dice and Tversky score the same overlapping foreground regions. Separate false-positive and false-negative weights change the Tversky score. View full-size image.Dice and Tversky Region Comparison by Atlas Nova. Illustration generated with AI for this article and checked against its text.

Turning a metric into a loss is a short step: negate it, or subtract it from one, and minimise. This is called direct loss minimisation, and it is what the Dice loss does; the Attention U-Net and V-Net architectures both train under it.⁠[4] The appeal for imbalanced data is immediate. A model that predicts background everywhere has no overlap with the lesion at all, so the Dice loss stays high and the gradient keeps pushing, whereas the same model can score deceptively well on an averaged pixel-wise penalty. Even in its simplest formulation the Dice loss is somewhat adapted to handle class imbalance, which is why it became a standard answer to the problem described in the previous section.⁠[4]

The instability that comes with the ratio

The same ratio that makes Dice robust also makes it awkward to optimise. The Dice loss gradient is inherently unstable, most evident with highly class-imbalanced data, where the gradient calculation involves small denominators.⁠[4] The reason is arithmetic rather than mysterious: the coefficient divides by the total size of the predicted and true regions, and when the predicted region is tiny, that denominator is tiny too, so a small change in the prediction can swing the loss and its gradient by a large amount. Early in training, when the model predicts almost nothing of the small structure, this is exactly the regime it is in. The loss that best expresses what is wanted is thus the one whose slope is least well behaved precisely where learning needs to start.

Tversky: pricing the two kinds of mistake separately

A useful generalisation separates the two ways a segmentation can fail. The Tversky index is closely related to the Dice coefficient but enables optimisation for output imbalance by assigning separate weights to false positives and false negatives.⁠[4] A false positive is background wrongly called foreground; a false negative is foreground wrongly called background. When the Dice loss is applied to class-imbalanced problems, the resulting segmentation often exhibits high precision but low recall, meaning the model is conservative and misses parts of the object, and assigning a greater weight to false negatives improves recall and gives a better balance of precision and recall. In practice the weight on false negatives is often set higher than the weight on false positives, most commonly 0.7 against 0.3. The Tversky index is closely related to the Dice similarity coefficient but assigns separate weights to false positives and false negatives.⁠[4]

Correcting the weights by volume

A third refinement addresses a subtler bias. Plain Dice treats every class in a multi-class problem as equally worth overlapping, which is again a poor assumption when one class is rare. Generalised Dice corrects the class weights by the inverse of their volume, so that a class occupying few pixels carries more weight in the overlap calculation.⁠[4] The reasoning mirrors the frequency weighting discussed earlier, but applies it inside the overlap measure rather than inside a per-pixel average. The class re-balancing properties of the Generalised Dice overlap have been proposed as a robust and accurate deep-learning loss for unbalanced tasks, and its behaviour has been examined against weighted cross entropy and the sensitivity function across 2D and 3D segmentation tasks with different rates of label imbalance.⁠[10]

What ties these variants together is a single move: stop letting the majority of pixels set the scale of the penalty. Cross entropy does that by averaging, and its Focal modulation does it by down-weighting easy examples. Overlap losses do it by measuring the agreement of regions, so that a small object predicted badly cannot hide inside a large correct background. The cost is a loss whose gradient is harder to follow and whose behaviour depends on how the two error types are weighted. Which of these costs is worth paying depends on the task, and the comparisons that pit the families against one another are taken up later.

Overlap losses fix the imbalance problem by measuring regions rather than summing pixels, and pay for it with a gradient that misbehaves exactly when the predicted region is small.

Losses that encode what the eye or the task cares about

The losses covered so far all assume that the thing worth getting right can be written down as a distance between numbers or an overlap between regions. That assumption fails whenever the real criterion lives in a human judgement, a physical cost, or a logical rule that the network's output has to satisfy. A family of losses has grown up around exactly those cases, each built by taking the criterion seriously and asking what arithmetic would express it.

An axial CT slice through the upper chest showing both lungs, the spine, ribs, and shoulder bones, with a small bright nodule circled in yellow in the left lung.
An axial CT slice through the upper chest showing both lungs, the spine, ribs, and shoulder bones, with a small bright nodule circled in yellow in the left lung. View full-size image.CT-Low-Dose-1.25-Lung-Calcified-Nodule by Ptrump16. CC BY-SA 4.0, via Wikimedia Commons. Scaled to 960 pixels wide; no crop or other changes by Atlas Nova.

When the judge is a human eye

Image restoration is the clearest case. A denoising or super-resolution network is judged by a person looking at the result, and a person does not add up squared differences. The squared error, ℓ2, had become the default and virtually only choice for the loss layer in image processing, and when the resulting image is to be evaluated by a human observer, perceptually motivated losses are important. Perceptually motivated losses were proposed because the resulting image is to be evaluated by a human observer, and the quality of results improves significantly with better loss functions even when the network architecture is left unchanged. Perceptually motivated losses were proposed to close this gap: the loss is built from something closer to what the observer notices, and the quality of results improves significantly with better loss functions even when the network architecture is left unchanged.⁠[5] The last clause is the important one for the theme of this section. The architecture was held fixed, so any improvement came from changing what the model was told to care about.

When the output has a natural geometry

Some outputs are not single numbers or single labels but collections, and the collection has its own notion of distance. Predicting a set of tags for a photograph is an example: many such problems come with a natural metric on the outputs that can be used to improve predictions. The Wasserstein loss is built on the Wasserstein distance, which provides a natural notion of dissimilarity for probability measures, and it was developed for multi-label learning precisely because many such problems come with a natural metric on the outputs that can be used to improve predictions. Optimising the exact distance is costly, so the practical method uses a regularised approximation that is efficiently computed, together with an extension of the distance from probability measures to unnormalised measures. The property that makes it useful is smoothness: the loss can encourage predictions to vary smoothly with respect to the chosen metric on the output space, so a small shift along that metric costs little and a large jump costs a lot.⁠[11]

Time series raise the same issue in a different form. Two sequences can be identical in shape but offset in time, and a point-by-point comparison punishes the offset as though the shapes disagreed. Dynamic time warping is the classical answer, but the paper takes advantage of a smoothed formulation of DTW, called soft-DTW, that computes the soft-minimum of all alignment costs. Soft-DTW takes a smoothed formulation of the warping discrepancy that computes the soft-minimum of all alignment costs, and shows that this smoothed version is a differentiable loss whose value and gradient can both be computed with quadratic time and space complexity. Because it is differentiable, a network that outputs time series can be trained by minimising its fit to ground-truth sequences in the soft-DTW sense, and the same geometry is well suited to averaging and clustering series.⁠[12]

When the requirement is a rule, not a number

A third kind of criterion is symbolic. A network may be asked to output a ranking, a path through a graph, or a set of labels subject to a logical constraint, and the constraint is a statement about which combinations are allowed rather than a distance. The semantic loss is derived from first principles to bridge neural output vectors and logical constraints, capturing how close the network is to satisfying the constraints on its output. In an experimental evaluation it guided the learner to (near-)state-of-the-art results on semi-supervised multi-class classification and significantly increased the ability to predict structured objects such as rankings and paths, which are tremendously difficult to learn.⁠[13]

When the cost is money or harm

The last case is the most direct. In many real applications the two kinds of mistake a classifier can make do not cost the same, and the asymmetry is a fact about the world rather than a property of the data. In many real applications the two kinds of mistake a classifier can make do not cost the same, and a metric factoring in information about a real-world problem, such as financial impact, is more directly interpretable for users than accuracy or F1. The Real-World-Weight Cross-Entropy loss allows real-world costs to be entered directly as weights, in both a binary and a single-label multiclass version, and the multiclass version also permits direct penalisation of probabilistic false positives, weighted by label, during training. The motivation is that a metric factoring in information about a real-world problem, such as financial impact, is more directly interpretable for users than accuracy or F1, and the design was compared against binary and categorical cross entropy and their weighted variants in scenarios emulating imbalanced classes, diagnostic error and reinforcement of social bias, using the MNIST dataset.⁠[14]

What unites these five losses is not their arithmetic but their starting point. Each begins with a statement of what actually counts as a bad outcome, whether that is a visible artefact, a displaced tag, a violated rule, or a costly mislabel, and then builds the penalty to match. The evidence that such choices change results, rather than merely re-describing them, is taken up in the sections that follow.

A loss that encodes the real criterion, perceptual, geometric, logical or monetary, can improve results with the network left untouched, because it changes what the model is being asked to care about.

Research

Choosing a loss changes the result

The claim that the loss layer matters is easy to assert and harder to demonstrate, because a change in results could always be credited to the network, the data, or the training schedule instead. The cleanest evidence comes from experiments that hold the architecture fixed and change only the penalty. Image restoration supplies one such case. The squared error had been the default and virtually only choice for the loss layer in image processing, and when perceptually motivated losses were compared against it, the quality of the results improved significantly with better loss functions even though the network architecture was left unchanged.⁠[5] Nothing about the model's capacity changed; only the arithmetic that told it what a bad output was. That is the strongest form the argument can take, because it removes every explanation except the loss itself.

A single loss built to cover a family

Segmentation offers a second test, and a more demanding one, because the comparison is not one loss against another but one loss against six. The Unified Focal loss is a hierarchical framework that generalises Dice and cross entropy-based losses for handling class imbalance, derived by classifying the existing Dice and cross entropy losses into a hierarchy and then reading the new loss off that structure.⁠[4] Because the older losses sit inside the framework as special cases reached by particular settings of its parameters, the comparison is between a general rule and the specific rules it contains, rather than between unrelated competitors.

The evaluation used five publicly available, class imbalanced medical imaging datasets: CVC-ClinicDB, the Digital Retinal Images for Vessel Extraction set, Breast Ultrasound 2017, Brain Tumour Segmentation 2020, and Kidney Tumour Segmentation 2019.⁠[4] These span 2D binary, 3D binary and 3D multiclass segmentation tasks, so a loss that won only on one kind of problem would show up as such. Across those tasks the proposed loss proved robust to class imbalance and consistently outperformed the six other Dice and cross entropy-based loss functions it was set against, and it was associated with a better balance between recall and precision.⁠[4] The recall-precision point matters as much as the headline: a loss can raise accuracy by becoming conservative, and a better balance means the gain did not come from simply trading one kind of error for the other.

The design of the comparison also speaks to a habit the field has been criticised for. Careful selection of the loss function is not widespread practice, and suboptimal losses are often chosen with consequences for performance, which is why large-scale comparisons are needed to inform the choice.⁠[4] Earlier comparisons had disagreed with one another, and one confounding factor identified was the degree of class imbalance in the datasets used, with low imbalance in the NBFS Skull-stripping dataset, moderate imbalance in the CVC-EndoSceneStill dataset, and a mixture of low and high in the datasets of Ma et al. (2021).⁠[4] A loss that looks best on a mildly imbalanced dataset need not look best on a severely imbalanced one. The Unified Focal result is therefore best read as evidence that a loss designed around the imbalance can beat the standard options across a range of imbalance levels, not as a claim that one rule wins everywhere.

Two clinical classifiers, one change

Two further studies make the same point in settings where the imbalance is extreme and the cost of a miss is high. In lung nodule classification, a 15-layer two-dimensional convolutional network was built to sort candidate patches from CT scans into nodule and non-nodule, and the Focal loss was applied to the training process to boost classification accuracy. Evaluated on the LIDC/IDRI dataset as extracted by the LUNA16 challenge, the method reached an accuracy of 97.2 percent, a sensitivity of 96.0 percent and a specificity of 97.3 percent.⁠[1] The imbalance here is the ordinary one for lesion detection: nodules are rare relative to the normal anatomy that surrounds them, so a per-pixel or per-patch average is dominated by the easy negative cases, and a loss that down-weights those easy cases shifts the model's effort toward the hard positives.

Lung sound classification provides the sharpest comparison of the group, because the same network was trained under two different losses and the results set side by side. A hybrid model passed spectrograms through a convolutional network and then through a long short-term memory network to classify four categories of lung sound, normal, crackles, wheezes, and both crackles and wheezes, with the Focal loss used to measure prediction error and handle data imbalance. When the classic cross entropy loss was substituted, the overall sensitivity, specificity, score and accuracy all decreased, from 52.78 percent to 51.94 percent, from 84.26 percent to 83.98 percent, from 68.52 percent to 67.96 percent, and from 76.39 percent to 75.97 percent respectively, under interpatient 10-fold cross validation.⁠[2] The gaps are modest, and honesty requires saying so. What the comparison establishes is direction rather than magnitude: with the architecture, the data and the splitting strategy all held constant, the choice of penalty moved every reported measure in the same direction.

What the pattern does and does not show

Read together, these results support a limited and useful conclusion. Changing the loss alone, with everything else fixed, can change the quality of what a model learns, and the direction of the change tends to favour a penalty built for the structure of the problem, whether that structure is a human viewer's sensitivity to artefacts, a severe imbalance between foreground and background, or a rare class the model keeps getting wrong. The image restoration case shows the effect in a setting where the loss was changed and the architecture left unchanged.⁠[5] It encodes a view of what a bad output is, and a view that matches the task produces a better model than one that does not.

What the pattern does not show is that any one of these losses is the right default. The comparisons disagree about which region-based or compound loss is best, and the degree of imbalance in the data is one reason they disagree.⁠[4] A loss tuned to one dataset's balance can underperform on another's, and the studies above each report results on their own benchmarks rather than a general ranking. The practical lesson is narrower and more durable: the loss is a design decision with measurable consequences, and it deserves the same scrutiny as the architecture. The sections that follow take up the settings where that decision becomes hardest, beginning with training data whose labels are themselves unreliable.

Holding the network fixed and changing only the penalty changes the results, which makes the loss a design decision rather than a detail.

Losses under noisy and imbalanced labels

The losses discussed so far assume that the targets they are compared against are correct. In real training sets that assumption often fails. Labels are entered by hand, inherited from older records, or produced by automated tools that make their own mistakes, and a deep network has enough capacity to memorise the errors along with the signal. The question for this section is what the choice of penalty does when the labels are wrong, and what it does when one class is far rarer than another.

Class frequency and true-class probability feed an adaptive weight that multiplies loss before a batch objective and model update, above two example cards.
Class frequency and true-class probability jointly inform an adaptive example weight. Two examples from the same minority class illustrate different emphasis according to difficulty. View full-size image.Adaptive Weighting for Imbalanced Classes by Atlas Nova. Illustration generated with AI for this article and checked against its text.

Cross entropy is not robust to noisy labels.⁠[15] The reason follows from its shape. Because the rule prices a confident mistake steeply, a model that has fitted a wrong label confidently will be pushed hard to keep that confidence, and the gradient from the mistake competes with the gradient from the genuine examples. The penalty that makes cross entropy good at learning clean data is the same penalty that makes it willing to absorb bad data.

The mean absolute error and its underfitting problem

One obvious alternative is to stop squaring or exponentiating the gap and simply take its absolute value. For binary classification there exist theoretical results on loss functions robust to label noise, and provides sufficient conditions on a loss function for risk minimisation to be tolerant of label noise in multiclass problems, showing that the loss based on the mean absolute value of error is inherently robust to label noise so that standard back propagation is enough to learn the true classifier even under label noise. The theoretical grounding is a set of sufficient conditions on a loss function for risk minimisation to be tolerant of label noise in multiclass problems, generalising earlier results that had been established only for binary classification.⁠[16]

Robustness, however, is not the same as accuracy. The mean absolute error can perform poorly with deep networks and challenging datasets.⁠[17] Several robust loss functions were found to suffer from a problem of underfitting.⁠[15] A loss that refuses to be excited by any single mistake is also a loss that learns slowly from the mistakes worth learning from.

A family between the two extremes

The way out is to treat the two rules as ends of a spectrum rather than as rivals. The generalised cross-entropy loss is a theoretically grounded set of noise-robust loss functions that can be seen as a generalisation of both the mean absolute error and categorical cross entropy. The proposed functions can be applied with any existing network architecture and training algorithm, and were reported to yield good performance across a wide range of noisy-label scenarios, with experiments on CIFAR-10, CIFAR-100 and FASHION-MNIST using synthetically generated noisy labels.⁠[17]

Normalisation, and the Active Passive Loss framework

A second line of attack asks whether robustness can be added to a loss rather than built into it. Applying a simple normalisation makes any loss robust to noisy labels, in the sense that the resulting risk is tolerant of the noise. But being robust is not sufficient for a loss to train an accurate network, and several robust loss functions were found to suffer from a problem of underfitting. The remedy is to combine two robust losses that mutually boost each other, a construction called the Active Passive Loss framework, whose family of losses was reported to outperform state-of-the-art methods by large margins on benchmark datasets, especially at large noise rates such as 60 percent or 80 percent incorrect labels.⁠[15]

When the imbalance is the problem

Noisy labels and imbalanced classes often arrive together, and the second has its own remedy. Class imbalance means the minority class, usually the one of interest, is outnumbered so heavily that a conventional classifier is subject to frequency bias, and learning a boundary between the minority and the majority becomes difficult. The dynamically weighted balanced loss assigns weights based on class frequency and on the predicted probability of the ground-truth class, so that the weighting adapts to the prediction scores and the gradient updates are driven by hard minority-class samples. The loss is shown to be classification calibrated, and experiments on highly imbalanced data from cyber intrusion detection, using the CICIDS2017 dataset, and medical imaging, using the ISIC2019 dataset, showed robust generalisation.⁠[18]

The adaptive part is what distinguishes it from simple frequency weighting. A fixed weight corrects for how many examples a class has; a weight that also depends on the predicted probability corrects for how well the model is doing on each instance, so an easy minority example is not over-weighted and a hard one is not lost in the average.

What these approaches share is a refusal to treat the training set as given. Each accepts that some labels are wrong or some classes are rare, and builds the penalty so that the model's effort lands where it is useful. The next sections take up settings where the target itself has more structure than a single category, and where the loss must respect an order or a grouping among outputs.

Robustness to bad labels and attention to rare classes pull in opposite directions, and the useful losses are the ones that hold both without letting either flatten the learning signal.

Losses beyond classification: detection, ordinal labels and instance separation

Classification asks which category an example belongs to, and the losses built for it assume the answer is a single choice from a fixed list. Many tasks do not fit that shape. A detector must say where an object is as well as what it is, an age estimator must respect that the labels have an order, and a segmentation model must keep the pixels of one object together while pushing different objects apart. Each of these needs a penalty that scores something richer than a category, and in each case the loss is built by asking what the output actually is.

Figure 1. Mean absolute error in age prediction by loss. Mean absolute error in years for a cross entropy classifier and a rank-consistent ordinal method on three face datasets. The source states: “MORPH-2 MAE RMSE 3.26 4.62 3.36 4.77 3.39 4.84 3.34 ± 0.07 4.74 ± 0.11 2.87 4.08 2.81 3.97 2.82 3.87 2.83 ± 0.03 3.97 ± 0.11 2.66 3.69 2.64 3.64 2.62 3.62 2.64 ± 0.02 3.65 ± 0.04 AFAD MAE RMSE 3.58 5.01 3.58 5.01 3.62 5.06 3.60 ± 0.02 5.03 ± 0.03 3.56 4.80 3.48 4.68 3.50 4.78 3.51 ± 0.04 4.75 ± 0.06 3.42 4.65 3.51 4.76 3.48 4.73 3.47 ± 0.05 4.71 ± 0.06 CACD MAE RMSE 5.74 8.20 5.68 8.09 5.53 7.92 5.65 ± 0.11 8.07 ± 0.14 5.36 7.61 5.40 7.78 5.37 7.70 5.38 ± 0.02 7.70 ± 0.09 5.25 7.41 5.25 7.50 5.24 7.52 5.25 ± 0.01 7.48 ± 0.06” (Cao et al. (2020)).⁠[19]

Boxes as distributions, not points

A one-stage object detector does its work densely: it classifies many candidate locations at once and regresses a bounding box for each. The classification branch is usually trained with the Focal loss, and the box location is commonly learned under a Dirac delta distribution, meaning the model commits to one exact set of coordinates.⁠[3] Two problems follow from that commitment. The quality estimate that the detector produces is used inconsistently between training and inference, and a single point cannot express the ambiguity of a box whose edges are genuinely uncertain in a cluttered scene.⁠[3]

The Generalized Focal loss addresses both by changing the representation rather than the network. The quality estimate is merged into the class prediction vector to form a joint representation of localisation quality and classification, and the box location is represented as a vector describing an arbitrary distribution over coordinates instead of one point. These representations carry continuous labels, which puts them beyond the reach of the original Focal loss, so the loss itself is generalised from its discrete form to a continuous version that can optimise them. On the COCO test-dev benchmark the method reached 45.0 percent average precision with a ResNet-101 backbone, above the 43.5 percent and 43.6 percent of two prior detectors under the same backbone and training settings, and the best model reached 48.2 percent single-model single-scale average precision at 10 frames per second on one graphics card.⁠[3] The lesson generalises past detection: when the target is a distribution rather than a point, the penalty has to be able to compare distributions.

When the labels have an order

Age estimation is a case of an ordering that ordinary classification throws away. Multi-category cross entropy treats the labels as unrelated slots, so it does not capture the relative ordering between labels, even though predicting 30 for a true age of 31 is nearly right and predicting 80 is not. A common fix equips a network with ordinal regression by turning the ordered targets into a set of binary classification subtasks, but that method suffers from inconsistencies among the different binary classifiers, which can disagree with one another.⁠[19]

The COnsistent RAnk Logits framework, or CORAL, resolves the inconsistency by construction, with theoretical guarantees for rank-monotonicity and for consistent confidence scores. It is architecture-agnostic and can extend an arbitrary state-of-the-art classifier to an ordinal task, and in an evaluation on face-image datasets for age prediction it reduced prediction error substantially compared with a reference ordinal regression network.⁠[19] The design point is that the ordering is a fact about the labels, and a loss that ignores it is discarding information the data already contains.

Pulling instances apart in feature space

Semantic segmentation labels every pixel, but it does not say which pixels belong to the same individual object. Instance segmentation needs that grouping, and one way to get it is to make the network's own representation do the work. The discriminative loss operates at the pixel level and encourages a convolutional network to map each pixel to a point in feature space so that pixels of the same instance lie close together while different instances are separated by a wide margin. Grouping then becomes a simple clustering step applied after the network, with no object proposals and no recurrent mechanism. The approach was reported to perform on par with more complex methods on the Cityscapes and CVPPP leaf segmentation benchmarks, and to avoid some limitations of the popular detect-and-segment approaches.⁠[20]

What these three losses have in common is that none of them merely re-weights an existing classification penalty. Each begins from the structure of its output, an uncertain box, an ordered label, a set of instances, and builds a penalty that can express that structure. Whether such choices leave the model better calibrated, and how the loss relates to the statistics of the problem, is taken up later.

When the output is a distribution, an ordered label or a grouping, the loss has to be built around that structure; a penalty designed for flat categories cannot see it.

Calibration, robustness and what the loss implies statistically

A classifier that is right most of the time can still be untrustworthy, because being right and knowing how right one is are separate properties. Calibration is the match between a model's stated confidence and its actual correctness: a model is well calibrated when the predictions it makes with 80 percent confidence are correct about 80 percent of the time. Miscalibration, the mismatch between confidence and correctness, makes a network's predictions hard to rely on, since a probability that does not mean what it says cannot be used to decide when to act, when to defer, or when to ask for a second opinion.⁠[21] The ideal is a network that is accurate, calibrated and confident at once, and the interesting finding is that the loss used in training moves a model along that triple without any change to its architecture.

The loss as a calibrating device

Cross entropy, the standard choice for classification, turns out not to produce well-calibrated networks. The Focal loss does: as opposed to the standard cross entropy loss, focal loss allows the training of models that are already very well calibrated, and when it is combined with temperature scaling, a post-hoc adjustment of confidence, it yields state-of-the-art calibrated models while preserving accuracy.⁠[21] The mechanism follows from what the loss rewards. Focal down-weights those easy examples, so the pressure to become ever more confident on them is removed, and confidence is left to track difficulty rather than being inflated across the board. The practical point is that calibration is not a separate problem to be fixed after training. It is partly a consequence of which mistakes the loss was built to punish.

What learning theory says about the choice of penalty

A different kind of guarantee comes from statistical learning theory, which asks how the choice of loss affects the rate at which a learned classifier approaches the best achievable error. Under a convexity assumption met by all the loss functions commonly used, the bound on the estimation error changes with the loss, and for classification the hinge loss emerges as the loss of choice: other things being equal, it leads to a convergence rate practically indistinguishable from the logistic loss rate and much better than the square loss rate, and if the hypothesis space is sufficiently rich, the bounds obtained for the hinge loss are not loosened by the thresholding stage that turns a score into a class decision.⁠[8] Two things are worth drawing out. The first is that the square loss, the default in so much of image processing, is the weakest of the three for classification in this analysis, which is a theoretical counterpart to the empirical complaints about it. The second is that logistic loss, the close relative of cross entropy, is nearly as good as hinge, which helps explain why cross entropy has remained the practical default despite the theoretical edge claimed for hinge.

Why squared error can still be a classification loss

That last tension has a resolution of its own. The L1 and L2 losses, absolute and squared error, are, quite surprisingly, justified classification objectives for deep networks, and the justification is a probabilistic interpretation in terms of expected misclassification.⁠[22] In other words, minimising squared error can be read as minimising a particular estimate of how often the classifier will be wrong, which is what a classification loss is supposed to do. The same investigation introduced two losses not typically used as deep-network objectives and showed that they are viable alternatives to the existing ones, and it examined how the choice of loss affects learning dynamics and the resulting classifier's robustness to various effects, on classical datasets.⁠[22] The lesson is not that all losses are equivalent; the convergence analysis above says otherwise. It is that the gap between a regression-style penalty and a classification-style one is narrower than the names suggest, because both can be given a reading in terms of the errors that matter.

Taken together, these results say that a loss carries statistical commitments beyond the arithmetic it performs. It implies something about how confident the resulting model will be, something about how fast its error shrinks with more data, and something about which quantity it is really estimating. Reading a loss that way turns the choice from a matter of convention into a claim that can be checked, and the settings where such claims run into trouble are covered later.

A loss implies more than a penalty: it shapes how confident the model becomes and how fast its error shrinks, and those implications can be stated and tested.

In practice

Losses in the clinic, the lab and the sensorimotor system

The argument that a loss is a design decision with measurable consequences is easiest to accept when the setting is one where a mistake has a visible cost. Medical imaging supplies several such settings, and they differ enough from one another to show the idea working under different pressures. In each, the loss is chosen to match the structure of the problem rather than inherited by default.

Segmenting structures that occupy little of the image

The segmentation benchmarks used to test the Unified Focal loss were chosen as class-imbalanced medical imaging datasets. The five datasets tested were CVC-ClinicDB, the Digital Retinal Images for Vessel Extraction set, Breast Ultrasound 2017, Brain Tumour Segmentation 2020 and Kidney Tumour Segmentation 2019.⁠[4] The tumours are the point. A kidney tumour is smaller than the kidney, and the kidney is smaller than the frame, so a loss that counts every pixel equally spends most of its effort on tissue nobody asked about. Across these five datasets, spanning 2D binary, 3D binary and 3D multiclass tasks, the Unified Focal loss proved robust to the imbalance and consistently outperformed the six Dice or cross entropy-based loss functions it was compared against, with a better recall-precision balance.⁠[4] The breadth matters as much as the result: a rule that won on one modality could be an accident of that modality, and this one held across several.

Two classifiers where a miss is expensive

Lung nodule classification presents the imbalance in its starkest form. A computer-aided detection system sorts candidate patches from CT scans into nodule and non-nodule. A 15-layer two-dimensional convolutional network was built for this sorting task and trained with the Focal loss to boost classification accuracy. On the LIDC/IDRI dataset as extracted by the LUNA16 challenge, the method reached an accuracy of 97.2 percent, a sensitivity of 96.0 percent and a specificity of 97.3 percent.⁠[1] Sensitivity counts the nodules that were found rather than the background that was correctly dismissed.

Lung sound classification tests the same idea on a signal rather than an image, and with a direct comparison built in. A hybrid model passed spectrograms of respiratory cycles through a convolutional network to extract features and then through a long short-term memory network to capture how those features unfold in time, sorting four categories: normal, crackles, wheezes, and both crackles and wheezes together.⁠[2] The Focal loss measured the prediction error and handled the imbalance among those categories. When the classic cross entropy loss was substituted for it, every reported measure fell: sensitivity from 52.78 percent to 51.94 percent, specificity from 84.26 percent to 83.98 percent, the combined score from 68.52 percent to 67.96 percent, and accuracy from 76.39 percent to 75.97 percent, under interpatient 10-fold cross validation.⁠[2] The architecture, the data and the way the data were split all stayed the same, so the only thing that changed was the arithmetic telling your model what a bad prediction was.

Denoising where the judge is a radiologist

Low-dose CT raises a different problem. Cutting the radiation dose raises the noise and the artefacts in the reconstructed image, which can weaken a radiologist's confidence in what the image shows, and the reconstruction problem is ill-posed. Most algorithms built for the task, including the deep learning ones, aim at minimising the mean squared error between the denoised image and the ground truth under generic penalties, and although that improves the peak signal-to-noise ratio, such methods can compromise the visibility of important structural details after aggressive denoising. A method built on a generative adversarial network with the Wasserstein distance and a perceptual loss takes a different route: the perceptual loss suppresses noise by comparing the perceptual features of the denoised output against those of the ground truth in an established feature space, while the adversarial part works on migrating the noise distribution from strong to weak. The result transfers knowledge of visual perception into the denoising task, so the method tries to lower the noise level and keep the critical information at the same time, and promising results were obtained on clinical CT images.⁠[23]

The loss function inside a reaching arm

The most striking place a loss function turns up is not a machine at all. Motor learning can be defined as changing performance so as to optimise some function of the task, such as accuracy, and the measure of accuracy that is optimised is called a loss function, which specifies how the central nervous system rates the relative success or cost of a particular movement outcome.⁠[24] Models of pointing had usually assumed a quadratic loss, in which the mean squared error is minimised.

To measure the real one, subjects performed a task while the experimenters controlled the skewness of the distribution of errors they experienced, and the loss function was inferred from how the subjects' average performance shifted in response. People turned out to use a loss whose cost rises approximately quadratically with error for small errors and significantly less than quadratically for large ones, which makes the system robust to outliers.⁠[24] The quadratic assumption, in other words, is a good approximation near the target and a poor one far from it, because a reaching arm does not pay an ever-steeper price for a wild miss. The same shape of question, what does a bad outcome actually cost, runs from a tumour boundary to a hand overshooting a cup.

The same question, what does a bad outcome cost, is answered by the loss in a segmentation network, in a denoiser and in a human arm.

Criticism

Limits of the loss as a stand-in for the goal

A loss function is a proxy, and every proxy is a simplification. The real goal in a medical segmentation task is a correct delineation of a tumour that a surgeon can trust; the real goal in image restoration is a picture a radiologist can read without being misled. Neither of those can be handed to an optimiser directly. What gets handed over instead is a number, and the model will pursue that number with complete indifference to everything the number leaves out. The gap between the number and the goal is where the limits of the whole approach live, and it is worth being concrete about the forms the gap takes.

The clearest case is the one that has run through this chapter: mean squared error as a stand-in for image quality. Most deep learning methods for low-dose CT denoising aim at minimising the mean squared error between the denoised image and the ground truth under generic penalties, and although this improves the peak signal-to-noise ratio, such methods can compromise the visibility of important structural details after aggressive denoising.⁠[23] The loss is doing its job. It is driving down exactly the quantity it was given, and the quantity it was given does not distinguish between a faint blur spread evenly across a smooth region and the same amount of error concentrated on the edge of a lesion. A model that smooths away a subtle structure can score well on the proxy while failing the goal, and no amount of further training on the same loss will correct it, because the loss never asked for the structure in the first place.

Overlap losses carry their own version of the problem. The Dice coefficient is a ratio, and the Dice loss gradient is inherently unstable, most evident with highly class-imbalanced data, where the gradient calculation involves small denominators.⁠[4] This is not a defect that better tuning removes; it follows from the arithmetic of dividing by the size of a small predicted region. Early in training, when the model predicts almost none of the small structure, the denominator is at its smallest and the gradient at its least reliable, so the loss that best expresses what is wanted is the one whose slope is worst behaved exactly where learning has to begin. A proxy can be well matched to the goal and still be a poor thing to optimise.

A third limit is that no single loss wins across the range of conditions a real problem presents. A loss tuned to one dataset's balance can underperform on another's, which means the choice cannot be settled once and carried everywhere. It has to be made against the conditions of the task at hand, and those conditions are often not known until the data have been examined.

The fourth limit is more mundane and perhaps more consequential. Careful selection of the loss function is not widespread practice, and suboptimal losses are often chosen with consequences for performance.⁠[4] The default is inherited rather than examined, and the cost is invisible because nothing in the training curve announces that a better penalty existed. That framing is a corrective to the habit, but it also concedes the difficulty: if the pairing must be made afresh for each setting, then the choice depends on expertise and judgement that not every project has.

What follows from all this is not that losses should be distrusted but that they should be read for what they leave out. A loss encodes a claim about which errors matter, and the claim can be checked against the goal it stands in for. When the two diverge, the fix is usually to change the claim, by adding a perceptual term, a region term, or a cost term, rather than to train longer on the same number. The question of how such choices might be made systematically, rather than by hand for each task, is taken up later.

A loss is a stand-in, and the useful question is always what the stand-in leaves out.

Where the idea is heading

The losses described in this chapter were mostly invented one at a time, each to answer a particular failure. A newer habit treats them instead as points on a single map. The Unified Focal loss was built by first sorting the Dice and cross entropy-based losses into a hierarchy, then deriving a general rule from that structure, so that the older losses reappear as special cases reached by setting its parameters to particular values.⁠[4] Read that way, choosing a loss stops being a search through unrelated candidates and becomes a matter of moving within a family whose members are already understood in relation to one another. A designer who knows where a familiar loss sits on the map can see which neighbouring rule might suit the data better, and why.

Four colored stages form a circular search on the left, while a weighted-loss formula and two numerical calculations appear on the right.
A conceptual search cycle proposes, trains, evaluates and refines candidate losses. The worked example shows why values from differently weighted objectives cannot alone establish which model is better. View full-size image.Composing and Selecting Loss Weights by Atlas Nova. Illustration generated with AI for this article and checked against its text.

The same survey, which examines how losses and metrics align with different learning objectives, also gives attention to multi-loss setups, arrangements that combine several loss terms so that competing goals are balanced within one training objective.⁠[6] The appeal is plain from the cases already covered. A denoiser judged by a human eye wants a perceptual term, a segmentation model on a rare lesion wants a region term, and a classifier whose mistakes carry different real-world costs wants those costs entered as weights. A single training run can carry all of these at once, with the relative weighting deciding how the model divides its effort. The open question is how those weights should be set, since each term pulls the model in a slightly different direction and the balance between them is itself a design choice.

Automated loss-function search is the direction the survey names as an open problem, alongside the development of robust and interpretable evaluation measures for increasingly complex tasks.⁠[6] The motivation follows from the limits described earlier: careful selection of a loss is not widespread practice, and the right choice depends on the balance of the particular dataset.⁠[4] If the choice depends that closely on the data, then leaving it to habit is costly, and searching over losses, or over the weights within a compound loss, is one way to make the decision empirically rather than by convention. What such a search would need is a reliable way to judge the result, which is why the pairing of loss and metric keeps returning.

None of this removes the underlying difficulty. A loss remains a stand-in for an outcome that cannot be handed to an optimiser directly, and a richer family of stand-ins does not settle which one matches the goal. What the trend does change is the scale of the question. Instead of asking which single penalty to adopt, the field is moving toward asking how a penalty should be composed, weighted and selected for the task in front of it, and toward treating that question as part of the design rather than an afterthought.

The direction of travel is from picking a loss to composing and searching over losses, with the choice treated as part of the design rather than inherited by default.

Key studies

YearStudySampleDesignFinding
2004Körding & Wolpert⁠[24]human subjects performing a pointing task with controlled error skewnessexperiment inferring the loss function from changes in average performancePeople use a loss that grows about quadratically for small errors and less than quadratically for large errors.
2017Zhao et al.⁠[5]comparison of l1, l2, MS-SSIM and Mix losses for image restoration, with numerical and visual resultsFor joint denoising and demosaicking, the network trained with the l1 loss reached a lower l2 loss than the network trained with the l2 loss.
2017Ghosh et al.⁠[16]sufficient conditions for noise-tolerant losses in multiclass classification, with experiments illustrating risk minimization under such lossesA loss built on the mean absolute value of error tolerates label noise by its nature, as Ghosh, Kumar and Sastry show.
2018Zhang & Sabuncu⁠[17]CIFAR-10, CIFAR-100 and FASHION-MNIST with synthetic noisy labelstraining deep networks with a family of losses that tolerate noisy labelsZhang and Sabuncu show that mean absolute error can perform poorly with deep networks on challenging datasets, and they present a set of losses that tolerate noisy labels and generalize mean absolute error and cross entropy.
2019Tran et al.⁠[1]lung nodule patches from the LIDC/IDRI dataset15-layer convolutional network trained with a focal loss function, 100 training epochs per evaluationThe model reached an accuracy of 97.2%, a sensitivity of 96.0% and a specificity of 97.3%.
2020Cao et al.⁠[19]three face image datasets for age estimationcomparison of cross entropy, ordinal regression and rank-consistent CORAL with ResNet-34On MORPH-2 the rank-consistent method reached a mean absolute error of 2.64 years against 3.34 years for cross entropy.
2020Ma et al.⁠[15]framework joining two losses that tolerate noisy labels, called Active Passive LossThe family of losses built by the Active Passive Loss framework consistently outperformed state-of-the-art methods by large margins, especially at noise rates such as 60% or 80% incorrect labels.
2020Mukhoti et al.⁠[21]computer vision and NLP datasets with a variety of network architecturescalibration experiments comparing focal loss with cross entropyFocal loss gave well calibrated models, and with temperature scaling it reached state-of-the-art calibration without losing accuracy.
2022Petmezas et al.⁠[2]the ICBHI 2017 Respiratory Sound Database with four lung sound classeshybrid CNN-LSTM network with focal loss under three data splitting strategiesOn the official 60/40 split the model reached a sensitivity of 47.37%, a specificity of 82.46% and an accuracy of 73.69%.
2022Yeung et al.⁠[4]five public class imbalanced medical imaging datasetscomparison of Unified Focal loss against six loss functions based on Dice or cross entropyDice scores for the asymmetric Unified Focal loss were 0.909 on CVC-ClinicDB, 0.803 on DRIVE and 0.824 on BUS2017.

See also

References

  1. Tran, G. S., Nghiem, T. P., Nguyen, V. T., Luong, C. M., & Burie, J. C. (2019). Improving Accuracy of Lung Nodule Classification Using Deep Learning with Focal Loss. Journal of Healthcare Engineering, 2019, 1-9. doi:10.1155/2019/5156416
  2. Petmezas, G., Cheimariotis, G. A., Stefanopoulos, L., Rocha, B., Paiva, R. P., Katsaggelos, A. K., & Maglaveras, N. (2022). Automated Lung Sound Classification Using a Hybrid CNN-LSTM Network and Focal Loss Function. Sensors, 22(3), 1232. doi:10.3390/s22031232
  3. Li, X., Wang, W., Lijun, W., Chen, S., Hu, X., Li, J., Tang, J., & Yang, J. J. (2020). Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection. arXiv. doi:10.48550/arxiv.2006.04388 Free full text
  4. Yeung, M., Sala, E., Schönlieb, C. B., & Rundo, L. (2022). Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medical image segmentation. Computerized Medical Imaging and Graphics, 95, 102026. doi:10.1016/j.compmedimag.2021.102026
  5. Zhao, H., Gallo, O., Frosio, I., & Kautz, J. (2017). Loss Functions for Image Restoration With Neural Networks. IEEE Transactions on Computational Imaging, 3(1), 47-57. doi:10.1109/tci.2016.2644865
  6. Terven, J., Cordova-Esparza, D. M., Romero-González, J. A., Ramírez-Pedraza, A., & Chávez-Urbiola, E. A. (2025). A comprehensive survey of loss functions and metrics in deep learning. Artificial Intelligence Review, 58(7). doi:10.1007/s10462-025-11198-7
  7. McNaughton, R. (1959). Scheduling with Deadlines and Loss Functions. Management Science, 6(1), 1-12. doi:10.1287/mnsc.6.1.1
  8. Rosasco, L., Vito, E. D., Caponnetto, A., Piana, M., & Verri, A. (2004). Are Loss Functions All the Same? Neural Computation, 16(5), 1063-1076. doi:10.1162/089976604773135104
  9. Mao, A., Mohri, M., & Zhong, Y. (2023). Cross-Entropy Loss Functions: Theoretical Analysis and Applications. arXiv. doi:10.48550/arxiv.2304.07288 Free full text
  10. Sudre, C. H., Li, W., Vercauteren, T., Ourselin, S., & Jorge Cardoso, M. (2017). Generalised Dice Overlap as a Deep Learning Loss Function for Highly Unbalanced Segmentations. Springer International Publishing. doi:10.1007/978-3-319-67558-9_28
  11. Frogner, C., Zhang, C., Mobahi, H., Araya‐Polo, M., & Poggio, T. (2015). Learning with a Wasserstein Loss. arXiv. doi:10.48550/arxiv.1506.05439 Free full text
  12. Cuturi, M., & Blondel, M. (2017). Soft-DTW: a Differentiable Loss Function for Time-Series. arXiv. doi:10.48550/arxiv.1703.01541 Free full text
  13. Xu, J., Zhang, Z., Tal, F., Liang, Y., & Broeck, G. V. d. (2017). A Semantic Loss Function for Deep Learning with Symbolic Knowledge. arXiv. doi:10.48550/arxiv.1711.11157 Free full text
  14. Ho, Y., & Wookey, S. (2020). The Real-World-Weight Cross-Entropy Loss Function: Modeling the Costs of Mislabeling. IEEE Access, 8, 4806-4813. doi:10.1109/access.2019.2962617
  15. Ma, X., Huang, H., Wang, Y., Romano, S., Erfani, S., & Bailey, J. (2020). Normalized Loss Functions for Deep Learning with Noisy Labels. arXiv. doi:10.48550/arxiv.2006.13554 Free full text
  16. Ghosh, A., Kumar, H., & Sastry, P. S. (2017). Robust Loss Functions under Label Noise for Deep Neural Networks. Proceedings of the AAAI Conference on Artificial Intelligence, 31(1). doi:10.1609/aaai.v31i1.10894
  17. Zhang, Z., & Sabuncu, M. R. (2018). Generalized Cross Entropy Loss for Training Deep Neural Networks with Noisy Labels. arXiv. doi:10.48550/arxiv.1805.07836 Free full text
  18. Fernando, K. R. M., & Tsokos, C. P. (2022). Dynamically Weighted Balanced Loss: Class Imbalanced Learning and Confidence Calibration of Deep Neural Networks. IEEE Transactions on Neural Networks and Learning Systems, 33(7), 2940-2951. doi:10.1109/tnnls.2020.3047335
  19. Cao, W., Mirjalili, V., & Raschka, S. (2020). Rank consistent ordinal regression for neural networks with application to age estimation. Pattern Recognition Letters, 140, 325-331. doi:10.1016/j.patrec.2020.11.008
  20. Brabandere, B. D., Neven, D., & Gool, L. V. (2017). Semantic Instance Segmentation with a Discriminative Loss Function. arXiv. doi:10.48550/arxiv.1708.02551 Free full text
  21. Mukhoti, J., Kulharia, V., Sanyal, A., Golodetz, S., Torr, P. H. S., & Dokania, P. K. (2020). Calibrating Deep Neural Networks using Focal Loss. arXiv. doi:10.48550/arxiv.2002.09437 Free full text
  22. Janocha, K., & Czarnecki, W. M. (2017). On Loss Functions for Deep Neural Networks in Classification. Schedae Informaticae, 1/2016. doi:10.4467/20838476si.16.004.6185
  23. Yang, Q., Yan, P., Zhang, Y., Yu, H., Shi, Y., Mou, X., Kalra, M. K., Zhang, Y., Sun, L., & Wang, G. (2018). Low-Dose CT Image Denoising Using a Generative Adversarial Network With Wasserstein Distance and Perceptual Loss. IEEE Transactions on Medical Imaging, 37(6), 1348-1357. doi:10.1109/tmi.2018.2827462
  24. Körding, K. P., & Wolpert, D. M. (2004). The loss function of sensorimotor learning. Proceedings of the National Academy of Sciences, 101(26), 9839-9842. doi:10.1073/pnas.0308394101

Cite this page: Atlas Nova editors. (2026). Loss function. Atlas Nova. https://velocer.io/atlas/loss-functions/