# S 形函数

S 形函数（sigmoid function）是一种 S 形（sigmoidal）曲线；在数学和机器学习中，该术语通常特指逻辑斯谛 S 形函数

\[ \sigma(z) = \frac{1}{1 + e^{-z}}, \]

它将任意实数映射到开区间 (0, 1)。它也被称为逻辑斯谛函数，或在数值库中称为 expit；SciPy 将其实现为 `scipy.special.expit(x) = 1/(1+exp(-x))`，并指出它是 logit 函数的反函数<sup>[1](https://cache-docs.scipy.org/doc/scipy/reference/generated/scipy.special.expit.html)</sup>。该曲线在 \( z = 0 \) 处经过 0.5，对大负输入趋近 0，对大正输入趋近 1，其输出总可解释为概率<sup>[2](https://openlearninglibrary.mit.edu/assets/courseware/v1/920d2b98ba33e5f1ef544c1e54d9a69d/asset-v1:MITx+6.036+1T2019+type@asset+block/notes_chapter_Logistic_regression.pdf)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义 | \( \sigma(z) = 1/(1 + e^{-z}) \)；输出位于 (0, 1)，在 \( z = 0 \) 处等于 0.5<sup>[1](https://cache-docs.scipy.org/doc/scipy/reference/generated/scipy.special.expit.html)</sup><sup> • </sup><sup>[2](https://openlearninglibrary.mit.edu/assets/courseware/v1/920d2b98ba33e5f1ef544c1e54d9a69d/asset-v1:MITx+6.036+1T2019+type@asset+block/notes_chapter_Logistic_regression.pdf)</sup> |
| 起源 | 由比利时（Belgium）数学家皮埃尔-弗朗索瓦·韦吕斯特（Pierre-François Verhulst，1804–1849）提出，可能最早于 1838 年用于描述人口增长；他于 1845 年将其命名为“logistic”<sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S1369848604000676)</sup> |
| 导数 | \( \sigma'(z) = \sigma(z)(1 - \sigma(z)) \)，可用函数值本身表示 |
| 与 tanh 的关系 | S 形函数可通过简单平移用双曲正切表示<sup>[4](https://arxiv.org/abs/0706.3163)</sup> |
| 统计作用 | 逻辑回归的逆连接函数，建模 \( P(y=1 \mid x) = \sigma(\theta^T x + \theta_0) \)<sup>[2](https://openlearninglibrary.mit.edu/assets/courseware/v1/920d2b98ba33e5f1ef544c1e54d9a69d/asset-v1:MITx+6.036+1T2019+type@asset+block/notes_chapter_Logistic_regression.pdf)</sup><sup> • </sup><sup>[21](https://online.stat.psu.edu/stat462/node/211/)</sup> |
| 主要训练缺点 | 饱和：其均值可能使随机初始化的深度网络的最顶层隐藏层进入饱和，从而导致梯度消失<sup>[5](https://yoshuabengio.org/en/publication/understanding-difficulty-training-deep-feedforward-neural-networks)</sup> |
| 生物测定形式 | 对称四参数逻辑斯谛（4PL）函数是常用的 S 形剂量-反应曲线；五参数逻辑斯谛（5PL）曲线处理不对称性<sup>[6](https://www.benthamscience.com/chapter/2226)</sup> |

## 数学性质

该函数光滑、单调递增，并介于 0 和 1 之间；它渐近趋于这两个值，但永不到达<sup>[2](https://openlearninglibrary.mit.edu/assets/courseware/v1/920d2b98ba33e5f1ef544c1e54d9a69d/asset-v1:MITx+6.036+1T2019+type@asset+block/notes_chapter_Logistic_regression.pdf)</sup>。其一阶导数为

\[ \sigma'(z) = \frac{e^{-z}}{(1 + e^{-z})^2} = \sigma(z) \cdot (1 - \sigma(z)), \]

因此斜率在 \( z = 0 \) 处最大，等于 0.25，并在两端尾部趋近于零。这种尾部行为称为饱和，是该函数在深度学习中大多数实际困难的根源。S 形函数通过简单平移与双曲正切相关：\( \tanh \) 覆盖范围 (−1, 1)，逻辑斯谛 S 形函数覆盖 (0, 1)<sup>[4](https://arxiv.org/abs/0706.3163)</sup>。

## 历史

该函数可能最早由比利时数学家皮埃尔-弗朗索瓦·韦吕斯特于 1838 年提出，用于描述人口增长；他于 1845 年为其命名。在接下来八十年里，它被独立重新发现数次，既用于人口增长，也用于描述自催化化学反应<sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S1369848604000676)</sup>。统计史学家约翰·克拉默（John Cramer）在 2004 年一项关于 logit 模型起源的研究中，将该函数作为增长曲线被广泛接受归功于人口学家雷蒙德·珀尔（Raymond Pearl）和洛厄尔·里德（Lowell Reed），将对韦吕斯特优先权的普遍承认归功于统计学家 G. Udny·尤尔（G. Udny Yule），并将其引入生物测定归功于约瑟夫·伯克森（Joseph Berkson）<sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S1369848604000676)</sup>。大约 1950 年，该函数从生物测定扩散到更广泛的统计学中<sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S1369848604000676)</sup>。

## 逻辑回归与概率建模

在统计学中，logit 是逻辑回归的连接函数，而逻辑斯谛 S 形函数是其逆连接函数<sup>[21](https://online.stat.psu.edu/stat462/node/211/)</sup>。线性逻辑分类器具有形式 \( h(x; \theta, \theta_0) = \sigma(\theta^T x + \theta_0) \)，因为输出始终位于 (0, 1)，可读作二元结果等于 1 的概率<sup>[2](https://openlearninglibrary.mit.edu/assets/courseware/v1/920d2b98ba33e5f1ef544c1e54d9a69d/asset-v1:MITx+6.036+1T2019+type@asset+block/notes_chapter_Logistic_regression.pdf)</sup>。训练最大化观测标签的似然，等价于最小化负对数似然损失

\[ \mathcal{L}_{\text{nll}}(g, y) = -\left( y \cdot \log g + (1 - y) \cdot \log(1 - g) \right), \]

它是参数的凸函数<sup>[2](https://openlearninglibrary.mit.edu/assets/courseware/v1/920d2b98ba33e5f1ef544c1e54d9a69d/asset-v1:MITx+6.036+1T2019+type@asset+block/notes_chapter_Logistic_regression.pdf)</sup>。logit 变换是 S 形函数的反函数，属于由特定概率分布导出的正则连接函数类；密切相关的 probit 连接基于正态累积分布，不是正则连接函数，但在某些情况下可改善拟合<sup>[7](https://digitalcommons.wayne.edu/jmasm/vol12/iss1/19/)</sup>。

S 形函数也作为校准工具出现。在约翰·普拉特（John Platt）为支持向量机提出的 Platt 标定中，训练一个额外的 S 形函数，将分类器输出映射为校准后的后验概率<sup>[8](https://www.researchgate.net/profile/John-Platt-2/publication/2594015_Probabilistic_Outputs_for_Support_Vector_Machines_and_Comparisons_to_Regularized_Likelihood_Methods/links/004635154cff5262d6000000/Probabilistic-Outputs-for-Support-Vector-Machines-and-Comparisons-to-Regularized-Likelihood-Methods.pdf)</sup>。机器学习研究者称之为 S 形校准或逻辑校准；《Statistics in Medicine》2023 年的一项综合比较发现，逻辑校准和 beta 校准在模拟研究中始终表现最佳，对经 logit 变换的概率估计进行校准通常优于对未变换估计的方法<sup>[9](https://onlinelibrary.wiley.com/doi/10.1002/sim.9921)</sup>。

## 在神经网络中的使用

作为神经网络激活函数，S 形函数引入非线性，并将每个神经元的输出归一化到 (0, 1)<sup>[10](https://amsdottorato.unibo.it/id/eprint/11928/1/AI-assisted%20climate%20downscaling%20for%20rapid%20assessment%20PHD%20tesi_FINALE.pdf)</sup>。在需要有界输出或门控式比例的场合，它仍是标准选择：LSTM 循环网络的遗忘门、输入门和输出门都应用 S 形函数来决定多少信息通过<sup>[11](https://www.theseus.fi/bitstream/handle/10024/501071/Bhuiyan_Rabbil_Thesis.pdf?sequence=2)</sup>，二元分类头通常以 S 形函数结尾，使输出可读作概率。

**饱和与梯度消失。** 该函数的尾部是其在深度前馈网络中的弱点。格洛罗特（Glorot）和本吉奥（Bengio）表明，当权重随机初始化时，逻辑斯谛 S 形函数的均值使其成为深度网络的不良激活选择，因为该均值可能尤其将最顶层隐藏层推入饱和；他们进一步指出，已饱和的单元可以自行脱离饱和，尽管只是逐渐地，这解释了训练期间观察到的平台期<sup>[5](https://yoshuabengio.org/en/publication/understanding-difficulty-training-deep-feedforward-neural-networks)</sup>。后来的一项分析区分了 S 形网络中梯度消失的两个来源：大参数和许多层之间的联合效应，并表明标准 \( \ell_2 \) 正则化解决第一个，而重参数化（对激活重新缩放）解决第二个，结论是 S 形激活仍是一个有力竞争者<sup>[12](https://arxiv.org/abs/2106.02260)</sup>。修正饱和激活函数的工作补充说，除了众所周知的非零中心性质外，逻辑斯谛函数在原点附近的斜率是使用它的深度网络难以训练的另一个原因<sup>[13](https://arxiv.org/abs/1602.05980)</sup>。

实证比较反映了这些困难。在一项文本标注任务上的激活函数基准测试中，S 形函数得分为 \( F_1 = 0.27 \pm 0.04 \)，是所测试函数中最低的，作者将其归因于标签预测不平衡，而 ReLU、tanh、ELU、Mish 及相关函数表现更好<sup>[14](https://pmc.ncbi.nlm.nih.gov/articles/PMC8455573/)</sup>。在用于生物活性建模的深度网络中，在 Wilcoxon 配对符号秩检验下，使用修正线性单元的网络在统计上优于 S 形和 tanh 激活<sup>[15](https://pmc.ncbi.nlm.nih.gov/articles/PMC5489441/)</sup>。

**数值实践。** 由于 S 形函数出现在二元交叉熵损失内部，框架将这两个操作合并。PyTorch 的 `BCEWithLogitsLoss` 将 S 形层和 `BCELoss` 合并到一个类中，这比先应用普通 S 形函数再应用 `BCELoss` 在数值上更稳定，因为合并层使用 log-sum-exp 技巧<sup>[16](https://docs.pytorch.org/docs/stable/generated/torch.nn.BCEWithLogitsLoss.html)</sup>。

## 剂量-反应曲线与生物测定

S 形曲线是剂量-反应关系的标准模型，其中响应概率随剂量或浓度上升<sup>[17](https://www.sciencedirect.com/science/article/pii/S0041008X16303374)</sup>。在生物测定开发中，常用的非线性剂量-反应曲线是 S 形曲线，例如对称四参数逻辑斯谛（4PL）函数或非对称五参数逻辑斯谛（5PL）曲线，后者考虑曲线不对称性以克服 4PL 的缺点<sup>[6](https://www.benthamscience.com/chapter/2226)</sup>。4PL 模型由

\[ Y = \frac{A - D}{1 + \left( x / C \right)^{B}} + D, \]

描述，其参数对应渐近线、中点与斜率；其“线性”区域定义为响应区域中心附近的浓度，在该处测试样品输入产生成正比的测定信号<sup>[18](https://www.tandfonline.com/doi/10.2144/btn-2019-0031)</sup>。当测量的响应为二元响应时，例如在给定剂量下的死亡或存活，可使用逻辑回归或 probit 回归生成剂量-反应曲线<sup>[19](https://stats.oarc.ucla.edu/sas/faq/how-can-i-generate-a-dose-response-curve-sas/)</sup>。逻辑模型和 probit 模型都不能拟合非对称的响应函数，或在中心概率区域具有更陡或更缓斜率的响应函数，这推动了用于质反应生物测定的广义逻辑斯谛模型的发展<sup>[20](https://digitalcommons.memphis.edu/facpubs/4019/)</sup>。

## References

1. [scipy.special.expit, SciPy v1.18.0 Manual](https://cache-docs.scipy.org/doc/scipy/reference/generated/scipy.special.expit.html)
2. [Notes, Chapter 5: Logistic Regression, MIT 6.036 Open Learning Library](https://openlearninglibrary.mit.edu/assets/courseware/v1/920d2b98ba33e5f1ef544c1e54d9a69d/asset-v1:MITx+6.036+1T2019+type@asset+block/notes_chapter_Logistic_regression.pdf)
3. [J. S. Cramer (2004). The early origins of the logit model. Studies in History and Philosophy of Biological and Biomedical Sciences 35(4): 613–626.](https://www.sciencedirect.com/science/article/abs/pii/S1369848604000676)
4. [Verhulst's logistic curve, arXiv:0706.3163](https://arxiv.org/abs/0706.3163)
5. [X. Glorot, Y. Bengio. Understanding the difficulty of training deep feedforward neural networks](https://yoshuabengio.org/en/publication/understanding-difficulty-training-deep-feedforward-neural-networks)
6. [Selecting an Appropriate Dose-Response Curve in Bioassay Development, Bentham Science](https://www.benthamscience.com/chapter/2226)
7. [The Probit Link Function in Generalized Linear Models for Data Mining Applications, Journal of Modern Applied Statistical Methods](https://digitalcommons.wayne.edu/jmasm/vol12/iss1/19/)
8. [J. Platt (1999). Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods](https://www.researchgate.net/profile/John-Platt-2/publication/2594015_Probabilistic_Outputs_for_Support_Vector_Machines_and_Comparisons_to_Regularized_Likelihood_Methods/links/004635154cff5262d6000000/Probabilistic-Outputs-for-Support-Vector-Machines-and-Comparisons-to-Regularized-Likelihood-Methods.pdf)
9. [F. M. Ojeda et al. (2023). Calibrating machine learning approaches for probability estimation: A comprehensive comparison. Statistics in Medicine.](https://onlinelibrary.wiley.com/doi/10.1002/sim.9921)
10. [AI-assisted climate downscaling for rapid assessment, PhD thesis, University of Bologna](https://amsdottorato.unibo.it/id/eprint/11928/1/AI-assisted%20climate%20downscaling%20for%20rapid%20assessment%20PHD%20tesi_FINALE.pdf)
11. [R. Bhuiyan. Recurrent Neural Networks with sigmoid-based LSTM gates, Theseus thesis](https://www.theseus.fi/bitstream/handle/10024/501071/Bhuiyan_Rabbil_Thesis.pdf?sequence=2)
12. [Regularization and Reparameterization Avoid Vanishing Gradients in Sigmoid-Type Networks, arXiv:2106.02260](https://arxiv.org/abs/2106.02260)
13. [Revise Saturated Activation Functions, arXiv:1602.05980](https://arxiv.org/abs/1602.05980)
14. [Universal activation function for machine learning, PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC8455573/)
15. [Deep-learning: investigating deep neural network hyper-parameters for modeling bioactivity data, PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC5489441/)
16. [BCEWithLogitsLoss, PyTorch documentation](https://docs.pytorch.org/docs/stable/generated/torch.nn.BCEWithLogitsLoss.html)
17. [Single toxin dose-response models revisited, Toxicology](https://www.sciencedirect.com/science/article/pii/S0041008X16303374)
18. [Best Practices in Bioassay Development to Support Registration of Biopharmaceuticals, BioTechniques](https://www.tandfonline.com/doi/10.2144/btn-2019-0031)
19. [How can I generate a dose response curve in SAS?, UCLA OARC FAQ](https://stats.oarc.ucla.edu/sas/faq/how-can-i-generate-a-dose-response-curve-sas/)
20. [M. A. El-Saidi, E. O. George. A Generalized Logistic Model for Quantal Response Bioassay](https://digitalcommons.memphis.edu/facpubs/4019/)
21. [online.stat.psu.edu](https://online.stat.psu.edu/stat462/node/211/)

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

Topic: 物质世界与数学 › 数学与统计学 › 数学分析与数学模型

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/sigmoid-function

English original: https://www.edgepedia.org/sigmoid-function
