# 胡伯损失

胡伯损失是一种用于稳健回归和机器学习的损失函数，它在残差较小时呈二次型，在残差较大时呈线性，与平方误差损失相比能降低离群值的影响。<sup>[1](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)</sup> 彼得·J·胡伯（Peter J. Huber）在1964年发表于《数理统计年鉴》（*The Annals of Mathematical Statistics*）的论文《位置参数的稳健估计》（Robust Estimation of a Location Parameter）中提出了它，此后它一直在统计学和深度学习中广泛使用。<sup>[2](https://cir.nii.ac.jp/crid/1361699995665709184)</sup><sup> • </sup><sup>[3](https://arxiv.org/abs/1911.02088)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | 当 \( |r| \le \delta \) 时对残差呈二次型，超过 δ 时呈线性（按 delta 缩放）；转折点 δ 分隔这两种情形<sup>[1](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)</sup><sup> • </sup><sup>[4](https://docs.pytorch.org/docs/stable/generated/torch.nn.modules.loss.HuberLoss.html)</sup> |
| 起源 | 彼得·J·胡伯（Peter J. Huber），《位置参数的稳健估计》，《数理统计年鉴》35(1): 73–101，1964年3月<sup>[2](https://cir.nii.ac.jp/crid/1361699995665709184)</sup> |
| 目的 | 结合平方误差在零点附近的快速收敛性与绝对误差在尾部的抗离群值能力<sup>[1](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)</sup> |
| 标准调参 | 当误差密度为正态时，取 c = 1.345 的胡伯 ψ 函数可给出约95%的相对效率<sup>[5](https://faculty.ucr.edu/~weixiny/material/yu%26yao17article%20cissc-Robust%20linear%20regression%20A%20review%20and%20comparison.pdf)</sup> |
| 凸性 | 该损失是凸的，因此可采用基于梯度的优化，但使用胡伯损失的非线性最小二乘问题不保证有唯一解，因为其目标函数可能有多个极小值<sup>[1](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)</sup><sup> • </sup><sup>[6](https://www.cs.cornell.edu/courses/cs4220/2026sp/lec/2026-04-10.html)</sup><sup> • </sup><sup>[22](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup> |
| 软件 | 已在 PyTorch（HuberLoss，默认 delta = 1.0）、SciPy（scipy.special.huber）、scikit-learn（HuberRegressor）和 TensorFlow 中实现<sup>[4](https://docs.pytorch.org/docs/stable/generated/torch.nn.modules.loss.HuberLoss.html)</sup><sup> • </sup><sup>[1](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)</sup><sup> • </sup><sup>[7](https://scikit-learn.org/stable/modules/linear_model.html)</sup> |
| 引用记录 | 截至2025年1月的数据，1964年论文已累计6,342次引用<sup>[8](https://explore.metascienceobservatory.org/papers/W2046033161)</sup> |

## 定义

对于残差 \( r \)——即模型预测与观测数据之差——阈值为 \( \delta > 0 \) 的胡伯损失为<sup>[1](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)</sup>

\[ \rho_\delta(r) = \begin{cases} \tfrac{1}{2} r^2, & |r| \le \delta, \\ \delta |r| - \tfrac{1}{2} \delta^2, & |r| > \delta. \end{cases} \]

其导数，即 M 估计框架中的影响函数，为<sup>[9](https://link.springer.com/article/10.1007/s41060-026-01285-5)</sup>

\[ \psi_\delta(r) = \rho_\delta'(r) = \begin{cases} r, & |r| \le \delta, \\ \delta\, \operatorname{sgn}(r), & |r| > \delta. \end{cases} \]

由于导数有界，极端残差对得分函数的贡献不能超过 \( \delta \)，这正是限制离群值杠杆作用的原因。平方误差损失具有无界的得分 \( \psi(r) = r \)，因此单个异常观测就能把普通最小二乘拟合任意拉远。<sup>[9](https://link.springer.com/article/10.1007/s41060-026-01285-5)</sup><sup> • </sup><sup>[5](https://faculty.ucr.edu/~weixiny/material/yu%26yao17article%20cissc-Robust%20linear%20regression%20A%20review%20and%20comparison.pdf)</sup> 胡伯损失是凸的，因此适合基于梯度的优化，但它不保证相关估计问题有唯一解，使用它的非线性最小二乘目标函数可能有多个极小值。<sup>[1](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)</sup><sup> • </sup><sup>[6](https://www.cs.cornell.edu/courses/cs4220/2026sp/lec/2026-04-10.html)</sup><sup> • </sup><sup>[22](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup>

阈值 δ 必须针对每个问题调参，因为它设定了平方误差与绝对误差两种情形之间的分界。<sup>[1](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)</sup> 在极限情形下，该损失在两个熟悉的估计量之间插值：当 \( c \to \infty \) 时，拟合表现如同普通最小二乘；当 \( c \to 0 \) 时，表现如同 \( L_1 \) 回归，其最小化点是中位数。<sup>[10](https://socr.umich.edu/DSPA2/DSPA2_notes/DSPA_Appendix_28_MathStat_Inference.html)</sup>

## 胡伯1964年论文中的起源

彼得·J·胡伯（1921—2025年间的瑞士数学家；1961年获苏黎世联邦理工学院（ETH Zurich）数学博士学位，1964年至1978年任苏黎世联邦理工学院统计学教授）在稳健统计学领域逐渐成形之际撰写了这篇论文。<sup>[11](https://doi.org/10.1002/0471725250)</sup> 该文处理污染正态分布下位置参数估计的渐近理论；在这类分布中，原型分布只是近似已知。文章给出了介于样本均值与样本中位数之间的估计量，并在特定意义下证明它们在所有平移不变估计量中渐近最稳健。<sup>[12](https://transferlab.ai/refs/huber_robust_1964/)</sup>

胡伯的方法不使用影响函数，而是对模型分布邻域上的方差使用极小极大条件；在一元位置问题中，两种准则得到相同的最优估计。<sup>[13](https://www.stat.ubc.ca/~ruben/website/Fatemah_thesis.pdf)</sup> 该文还开创了 M 估计量这一类别；它通过用稳健准则替换最小二乘准则，推广了普通最小二乘估计量和最大似然估计量。<sup>[14](https://sites.duke.edu/djepapers/files/2016/10/Song_DJE.pdf)</sup> 在回归中，系数向量 \( \beta \) 的 M 估计最小化 \( \sum_{i=1}^n \rho\big((y_i - x_i^T \beta)/\hat{\sigma}\big) \)，其中 \( \rho \) 是稳健损失，\( \hat{\sigma} \) 是误差尺度估计。<sup>[5](https://faculty.ucr.edu/~weixiny/material/yu%26yao17article%20cissc-Robust%20linear%20regression%20A%20review%20and%20comparison.pdf)</sup>

## 稳健性性质与局限

**正态误差下的效率。** 胡伯建议实践中在 ψ 函数中取 \( c = 1.345 \)，这一选择在误差密度为正态时产生约95%的相对效率；相比之下，最小绝对偏差估计量在正态误差下的效率仅为0.64。<sup>[5](https://faculty.ucr.edu/~weixiny/material/yu%26yao17article%20cissc-Robust%20linear%20regression%20A%20review%20and%20comparison.pdf)</sup> scikit-learn 文档对其 HuberRegressor 给出了相应建议：将参数 epsilon 设为1.35，以达到95%的统计效率。<sup>[7](https://scikit-learn.org/stable/modules/linear_model.html)</sup>

**该损失不能防范的情形。** 使用胡伯损失的 M 估计能抵抗异常的 \( y \) 观测，但仍对高杠杆点——即在预测变量 \( x \) 上取值极端的观测——敏感；其崩溃点为 \( 1/n \)，随着样本量增大趋于零。<sup>[5](https://faculty.ucr.edu/~weixiny/material/yu%26yao17article%20cissc-Robust%20linear%20regression%20A%20review%20and%20comparison.pdf)</sup> 在迭代重加权最小二乘表述中，胡伯权重给小残差权重1，并随残差增大而减小权重，但权重永远不会恰好为零，因此离群值是被降权而不是被完全剔除；这与图基双平方（Tukey's bisquare）形成对比：后者可以完全拒绝极端离群值，但缺乏唯一解，并可能停滞在局部最优。<sup>[15](https://stats.oarc.ucla.edu/stata/dae/robust-regression/)</sup><sup> • </sup><sup>[16](https://jfukuyama.github.io/teaching/stat670/notes/lecture-10.html)</sup>

## 概率解释

标准的概率解读将胡伯损失与胡伯密度联系起来；在胡伯密度下，损失最小化点是最大似然估计，但这种密度难以解释，因此常用超参数搜索来选择转折点。<sup>[3](https://arxiv.org/abs/1911.02088)</sup> 另一种解释将最小化胡伯损失与最小化两个拉普拉斯分布之间 Kullback–Leibler 散度的上界联系起来：一个分布对应真值中的噪声，另一个对应预测中的噪声；拉普拉斯尺度与转折点直接相关，因此近似标签噪声量提供了一种直观选择 δ 的方法。这一解释已在 Faster R-CNN 和 RetinaNet 目标检测器上得到演示。<sup>[3](https://arxiv.org/abs/1911.02088)</sup>

## 实现

主要数值库和机器学习库直接提供该损失。

- **PyTorch** 提供 `HuberLoss`，默认 `delta = 1.0`；当 \( |x_n - y_n| < \delta \) 时，逐元素损失为 \( 0.5(x_n - y_n)^2 \)，否则为 \( \delta(|x_n - y_n| - 0.5\delta) \)。当 delta 为1时，该损失等价于 `SmoothL1Loss`；一般而言，两者相差一个 delta 因子。<sup>[4](https://docs.pytorch.org/docs/stable/generated/torch.nn.modules.loss.HuberLoss.html)</sup>
- **SciPy** 提供 `scipy.special.huber`（在0.15.0版中加入），作为稳健统计和机器学习中的损失，并提供光滑近似 `pseudo_huber`。<sup>[1](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)</sup>
- **scikit-learn** 提供 `HuberRegressor`，它对被 epsilon 参数判定为离群值的样本应用线性损失；与 TheilSen 或 RANSAC 回归器不同，它是对离群值降权而不是忽略它们；一旦设定 epsilon，它便具有尺度不变性。<sup>[7](https://scikit-learn.org/stable/modules/linear_model.html)</sup>
- **TensorFlow** 提供 `tf.compat.v1.losses.huber_loss`，其中 delta 定义为函数从二次变为线性的点。<sup>[17](https://www.tensorflow.org/api_docs/python/tf/compat/v1/losses/huber_loss?authuser=365)</sup>

梯度提升机也将胡伯损失列为连续响应的标准损失之一，与高斯 \( L_2 \)、拉普拉斯 \( L_1 \) 和分位数损失并列。<sup>[18](https://pmc.ncbi.nlm.nih.gov/articles/PMC3885826/)</sup>

## 应用

在计算机视觉中，胡伯损失的光滑 \( L_1 \) 形式是 Fast 和 Faster R-CNN 系列目标检测器中边界框的标准回归损失，此后大多数使用胡伯损失的检测论文都采用这一形式。<sup>[3](https://arxiv.org/abs/1911.02088)</sup> 在稳健统计中，胡伯型 M 估计量是存在离群值时线性回归最常用的方法之一；带有伴随尺度估计的胡伯准则保留了最小绝对偏差的稳健性，同时在不存在离群值或重尾误差时提高了效率。<sup>[19](https://abjournals.org/ajmss/6/3/review-of-some-robust-estimators-in-multiple-linear-regressions-in-the-presence-of-outliers)</sup><sup> • </sup><sup>[20](https://pmc.ncbi.nlm.nih.gov/articles/PMC4570200/)</sup>

**自适应变体。** 自适应胡伯回归通过让稳健化参数随样本量、维数和数据矩自适应，来处理重尾数据，从而在偏差与稳健性之间取得平衡。理论刻画了一个急剧的相变：当矩阶 \( \delta \ge 1 \) 时，即使数据不具备次高斯性质，估计量也满足次高斯型的偏差界；而在 \( 0 < \delta < 1 \) 的情形下，无法获得比某个较慢速率更快的收敛速度。<sup>[21](https://arxiv.org/abs/1706.06991)</sup>

**光滑替代。** 伪胡伯损失（也称沙博尼耶损失）是一种处处可微的近似：\( \rho_\delta^{\mathrm{PH}}(r) = \delta^2\big(\sqrt{1 + (r/\delta)^2} - 1\big) \)，其得分像胡伯损失一样在 \( \pm\delta \) 处饱和，但在 \( |r| \approx \delta \) 附近平滑过渡，从而在保持凸性和有界影响的同时改善优化器稳定性。<sup>[9](https://link.springer.com/article/10.1007/s41060-026-01285-5)</sup>

## References

1. [scipy.special.huber, SciPy v1.18.0 Manual](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.huber.html)
2. [Peter J. Huber, "Robust Estimation of a Location Parameter", CiNii Research record](https://cir.nii.ac.jp/crid/1361699995665709184)
3. [Barron, J. T. (2019). "An Alternative Probabilistic Interpretation of the Huber Loss". arXiv:1911.02088](https://arxiv.org/abs/1911.02088)
4. [HuberLoss, PyTorch documentation](https://docs.pytorch.org/docs/stable/generated/torch.nn.modules.loss.HuberLoss.html)
5. [Yu, C., Yao, W. (2017). "Robust linear regression: A review and comparison". Communications in Statistics – Simulation and Computation](https://faculty.ucr.edu/~weixiny/material/yu%26yao17article%20cissc-Robust%20linear%20regression%20A%20review%20and%20comparison.pdf)
6. [CS 4220: Numerical Analysis, Cornell University lecture notes](https://www.cs.cornell.edu/courses/cs4220/2026sp/lec/2026-04-10.html)
7. [1.1. Linear Models, scikit-learn 1.9.1 documentation](https://scikit-learn.org/stable/modules/linear_model.html)
8. [Robust Estimation of a Location Parameter, Metascience Observatory Explorer](https://explore.metascienceobservatory.org/papers/W2046033161)
9. [Influence functions for Gaussian process hyperparameter estimation, International Journal of Data Science and Analytics](https://link.springer.com/article/10.1007/s41060-026-01285-5)
10. [DSPA2: Data Science and Predictive Analytics, University of Michigan](https://socr.umich.edu/DSPA2/DSPA2_notes/DSPA_Appendix_28_MathStat_Inference.html)
11. [Robust Statistics, Wiley Series in Probability and Statistics](https://doi.org/10.1002/0471725250)
12. [Huber, Robust Estimation of a Location Parameter (1964), TransferLab, appliedAI Institute](https://transferlab.ai/refs/huber_robust_1964/)
13. [Thesis on robust estimates of multivariate location and scatter, University of British Columbia](https://www.stat.ubc.ca/~ruben/website/Fatemah_thesis.pdf)
14. [Song (2016). "3.3 Robust Regressions", Duke Journal of Economics](https://sites.duke.edu/djepapers/files/2016/10/Song_DJE.pdf)
15. [Robust Regression, UCLA OARC Stats Data Analysis Examples](https://stats.oarc.ucla.edu/stata/dae/robust-regression/)
16. [Stat 470/670 Lecture 10: Robust regression, lecture notes](https://jfukuyama.github.io/teaching/stat670/notes/lecture-10.html)
17. [tf.compat.v1.losses.huber_loss, TensorFlow v2.16.1 API](https://www.tensorflow.org/api_docs/python/tf/compat/v1/losses/huber_loss?authuser=365)
18. [Natekin, A., Knoll, A. (2013). "Gradient boosting machines, a tutorial". Frontiers in Neurorobotics (PMC)](https://pmc.ncbi.nlm.nih.gov/articles/PMC3885826/)
19. [Alanamu et al. (2023). "Review of Some Robust Estimators in Multiple Linear Regressions in the Presence of Outlier(s)", African Journal of Mathematics and Statistics Studies 6(3)](https://abjournals.org/ajmss/6/3/review-of-some-robust-estimators-in-multiple-linear-regressions-in-the-presence-of-outliers)
20. [A selective review of robust variable selection with applications in bioinformatics (PMC)](https://pmc.ncbi.nlm.nih.gov/articles/PMC4570200/)
21. [Fan, Xue, Zou (2017). "Adaptive Huber Regression". arXiv:1706.06991](https://arxiv.org/abs/1706.06991)
22. [4.1.4.2. Nonlinear Least Squares Regression](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Estimation theory and estimator families › Robust statistics and resampling › Robust regression and outliers in modeling

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/huber-loss

English original: https://www.edgepedia.org/huber-loss
