{"url":"/method/balanced-l1-loss","slug":"balanced-l1-loss","name":"Balanced L1 Loss","full_name":"Balanced L1 Loss","full_name_withheld":false,"description_markdown":"**Balanced L1 Loss** is a loss function used for the object detection task. Classification and localization problems are solved simultaneously under the guidance of a multi-task loss since\r\n[Fast R-CNN](https://paperswithcode.com/method/fast-r-cnn), defined as:\r\n\r\n$$ L\\_{p,u,t\\_{u},v} = L\\_{cls}\\left(p, u\\right) + \\lambda\\left[u \\geq 1\\right]L\\_{loc}\\left(t^{u}, v\\right) $$\r\n\r\n$L\\_{cls}$ and $L\\_{loc}$ are objective functions corresponding to recognition and localization respectively. Predictions and targets in $L\\_{cls}$ are denoted as $p$ and $u$. $t\\_{u}$ is the corresponding regression results with class $u$. $v$ is the regression target. $\\lambda$ is used for tuning the loss weight under multi-task learning. We call samples with a loss greater than or equal to 1.0 outliers. The other samples are called inliers.\r\n\r\nA natural solution for balancing the involved tasks is to tune the loss weights of them. However, owing to the unbounded regression targets, directly raising the weight of localization loss will make the model more sensitive to outliers. These outliers, which can be regarded as hard samples, will produce excessively large gradients that are harmful to the training process. The inliers, which can be regarded as the easy samples, contribute little gradient to the overall gradients compared with the outliers. To be more specific, inliers only contribute 30% gradients average per sample compared with outliers. Considering these issues, the authors introduced the balanced L1 loss, which is denoted as $L\\_{b}$.\r\n\r\nBalanced L1 loss is derived from the conventional smooth L1 loss, in which an inflection point is set to separate inliers from outliners, and clip the large gradients produced by outliers with a maximum value of 1.0, as shown by the dashed lines in the Figure to the right. The key idea of balanced L1 loss is promoting the crucial regression gradients, i.e. gradients from inliers (accurate samples), to rebalance\r\nthe involved samples and tasks, thus achieving a more balanced training within classification, overall localization and accurate localization. Localization loss $L\\_{loc}$ uses balanced L1 loss is defined as:\r\n\r\n$$ L\\_{loc} = \\sum\\_{i\\in{x,y,w,h}}L\\_{b}\\left(t^{u}\\_{i}-v\\_{i}\\right) $$\r\n\r\nThe Figure to the right shows that the balanced L1 loss increases the gradients of inliers under the control of a factor denoted as $\\alpha$. A small $\\alpha$ increases more gradient for inliers, but the gradients of outliers are not influenced. Besides, an overall promotion magnification controlled by γ is also brought in for tuning the upper bound of regression errors, which can help the objective function better balancing involved tasks. The two factors that control different aspects are mutually enhanced to reach a more balanced training.$b$ is used to ensure $L\\_{b}\\left(x = 1\\right)$ has the same value for both formulations in the equation below.\r\n\r\nBy integrating the gradient formulation above, we can get the balanced L1 loss as:\r\n\r\n$$ L\\_{b}\\left(x\\right) = \\frac{\\alpha}{b}\\left(b|x| + 1\\right)ln\\left(b|x| + 1\\right) - \\alpha|x| \\text{ if } |x| < 1$$\r\n\r\n$$ L\\_{b}\\left(x\\right) = \\gamma|x| + C \\text{ otherwise } $$\r\n\r\nin which the parameters $\\gamma$, $\\alpha$, and $b$ are constrained by $\\alpha\\text{ln}\\left(b + 1\\right) = \\gamma$. The default parameters are set as $\\alpha = 0.5$ and $\\gamma = 1.5$","description_state":"present","introduced_year":null,"introduced_by":{"title":null,"paper":null,"first_author":null,"n_authors":0,"url_abs":null,"archive_paper_url":null},"source":{"url":"http://arxiv.org/abs/1904.02701v1","title":"Libra R-CNN: Towards Balanced Learning for Object Detection","url_on_a_paper_host":true},"code_snippet_url":"https://github.com/OceanPang/Libra_R-CNN/blob/5d6096f39b90eeafaf3457f5a39572fe5e991808/mmdet/models/losses/balanced_l1_loss.py#L9","code_snippet_url_on_a_code_host":true,"categories":[{"area":"General","area_id":"general","collection":"Loss Functions","url":"/methods/category/loss-functions","pwc_aliases":[]}],"n_papers_tagged":7,"archive_num_papers":null,"papers_newest_first":[{"paper":null,"title":"Enhancing Tree Type Detection in Forest Fire Risk Assessment: Multi-Stage Approach and Color Encoding with Forest Fire Risk Evaluation Framework for UAV Imagery","date":"2024-07-27","arxiv_id":"2407.19184","n_code_links":0,"syntology":null},{"paper":"/paper/vision-based-food-nutrition-estimation-via","title":"Vision-based Food Nutrition Estimation via RGB-D Fusion Network","date":"2023-10-25","arxiv_id":null,"n_code_links":1,"syntology":null},{"paper":null,"title":"Fracture Detection in Wrist X-ray Images Using Deep Learning-Based Object Detection Models","date":"2021-11-14","arxiv_id":"2111.07355","n_code_links":0,"syntology":null},{"paper":null,"title":"Towards Balanced Learning for Instance Recognition","date":"2021-08-23","arxiv_id":"2108.10175","n_code_links":0,"syntology":null},{"paper":"/paper/foodlogodet-1500-a-dataset-for-large-scale","title":"FoodLogoDet-1500: A Dataset for Large-Scale Food Logo Detection via Multi-Scale Feature Decoupling Network","date":"2021-08-10","arxiv_id":"2108.04644","n_code_links":1,"syntology":null},{"paper":null,"title":"PBRnet: Pyramidal Bounding Box Refinement to Improve Object Localization Accuracy","date":"2020-03-10","arxiv_id":"2003.04541","n_code_links":0,"syntology":null},{"paper":"/paper/libra-r-cnn-towards-balanced-learning-for","title":"Libra R-CNN: Towards Balanced Learning for Object Detection","date":"2019-04-04","arxiv_id":"1904.02701","n_code_links":6,"syntology":null}],"papers_shown":7,"tasks":[{"task":"/task/object-detection","name":"Object Detection","papers":3},{"task":"/task/object-detection-1","name":"object-detection","papers":3},{"task":"/task/ensemble-learning","name":"Ensemble Learning","papers":1},{"task":"/task/fire-detection","name":"Fire Detection","papers":1},{"task":"/task/food-recommendation","name":"Food recommendation","papers":1},{"task":"/task/fracture-detection","name":"Fracture detection","papers":1},{"task":"/task/management","name":"Management","papers":1},{"task":"/task/medical-object-detection","name":"Medical Object Detection","papers":1},{"task":"/task/nutrition","name":"Nutrition","papers":1},{"task":"/task/object-localization","name":"Object Localization","papers":1},{"task":"/task/transfer-learning","name":"Transfer Learning","papers":1}],"tasks_shown":11,"n_tasks":11,"usage_by_year":[{"year":"2019","papers":1},{"year":"2020","papers":1},{"year":"2021","papers":3},{"year":"2023","papers":1},{"year":"2024","papers":1}],"row_source":"embedded","archive":{"source":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","archive_url":"https://paperswithcode.com/method/balanced-l1-loss"},"syntology_read_at":"2026-09-24T18:15:14+00:00"}