Dictionary of Applied Machine Learning: 151 machine-learning terms, each with a definition, a figure, citations and a Python demo · All terms · Demos · Start here

sigmoid function

Updated on 2026-11-22

Readiness 100/100

▶ Run the Python demo Open in Colab Typeset PDF LaTeX source Markdown Cite this entry

See also logistic regression

The sigmoid function maps the real line into the open interval $(0, 1)$. It translates the real-valued score of a binary classifier into an estimate for the probability of a specific label value. It is smooth and strictly increasing, with a derivative that approaches zero as the magnitude of the argument grows. Machine learning (ML) uses it in two roles: as an activation function inside a neuron, and as part of the log-likelihood function for learning the model parameters of a probabilistic model.

Figure produced by the Python demo of the entry sigmoid function
Figure written by the entry's Python demo sigmoid.py, which recomputes what the entry states: the script block by block · open in Colab

Definition

B-shapeA frost warning for Krems an der Donau (Austria) has to say how likely frost is, not only whether it is expected. Fig. 1 shows the air temperature measured at $06{:}00$ (UTC) at that station. A classifier that warns of frost reads the $06{:}00$ reading of a day, its feature vector ${\mathbf x}$ with this single feature, and delivers a real-valued score $h({\mathbf x})$. The classification is a threshold: a frost warning for the next day is issued if and only if $h({\mathbf x}) > 0$, and the magnitude $|h({\mathbf x})|$ measures the confidence in that warning. In practice it is often more useful to state a probability. The sigmoid function translates the score $h({\mathbf x})$ into a number between $0$ and $1$ that can be read as the probability of frost, as Fig. 1 shows for its last day.

Figure 1 of the entry sigmoid
Figure 1: Six consecutive days at Krems an der Donau, each stem the air temperature measured at $06{:}00$ (UTC) that day. The reading of the last of them is the feature vector $\featurevec$ a classifier reads, from which it computes the score $\hypothesis(\featurevec) = 2.077$. That score is positive, so a frost warning is issued, and the sigmoid function turns it into $\sigmoid(2.077) \approx 0.89$, an $89$ percent probability of frost on 21/01. Data generated by pythondemos/sigmoid.py
The sigmoid function maps the real line into the open interval $(0, 1)$. It is the function $\sigma: \mathbb{R} \rightarrow (0,1)$ given by \[ \sigma(z) := \frac{1}{1 + e^{-z}} \text{.} \] It rises from $\sigma(z) \rightarrow 0$ as $z \rightarrow -\infty$ to $\sigma(z) \rightarrow 1$ as $z \rightarrow +\infty$, and passes through $\sigma(0) = 1/2$ (see Fig. 2). It is also called the logistic function. For two classes with scores $z$ and $0$, the softmax function returns the pair $\big(\sigma(z), 1 - \sigma(z)\big)$, so the sigmoid function is the softmax function for two classes: it delivers the probability of one class, and the other class has the complementary probability.
Figure 2 of the entry sigmoid
Figure 2: The sigmoid function $\sigmoid(z) = 1/(1 + e^{-z})$ maps the real line into the open interval $(0,1)$, with $\sigmoid(0) = 1/2$
The sigmoid function is smooth and strictly increasing, and it satisfies the symmetry $\sigma(-z) = 1 - \sigma(z)$ (Bishop, 2006, Sect. 4.2). Its derivative is available in closed form, and in terms of the function itself (Bishop, 2006, Sect. 4.3.2, Eq. (4.88)), \[ \sigma'(z) = \sigma(z)\big(1 - \sigma(z)\big) \text{.} \] These properties make the sigmoid function a popular choice for the activation function of an artificial neural network (ANN). One drawback of that choice is that the derivative decreases quickly as the argument grows in magnitude, which slows the progress of gradient-based learning methods, the vanishing gradient problem. The vanishing gradient problem is why sigmoidal activation functions are rarely used in the hidden layers of feedforward deep nets, where other activation functions such as the rectified linear unit (ReLU) are preferred (Goodfellow et al., 2016, Sect. 6.3.2).

B-frostA probabilistic model for a binary label uses the sigmoid function to turn a score into a probability. Let the label $y$ be either $1$ or $-1$, and let the score be ${\mathbf w}^{\top} {\mathbf x}$ with model parameters ${\mathbf w}$. The model reads \[ \mathbb{P}\left(y = 1 \mid {\mathbf x}\right) = \sigma\big({\mathbf w}^{\top} {\mathbf x}\big) \text{,} \qquad \mathbb{P}\left(y = -1 \mid {\mathbf x}\right) = \sigma\big(-{\mathbf w}^{\top} {\mathbf x}\big) \text{,} \] where the second follows from the symmetry $\sigma(-z) = 1 - \sigma(z)$. Both cases are the single expression $\sigma(y \, {\mathbf w}^{\top} {\mathbf x})$, which is where the sigmoid function enters the log-likelihood. For a training set $\mathcal{D}^{(\rm train)} = \big\{ \left( {\mathbf x}^{(r)},y^{(r)} \right) \big\}_{r=1}^{m}$ of labeled data points, the log-likelihood of the model parameters is \[ \sum_{r=1}^{m} \ln \sigma\big( y^{(r)} {\mathbf w}^{\top} {\mathbf x}^{(r)} \big) \text{.} \] Maximizing it over ${\mathbf w}$ is maximum likelihood estimation, and it is logistic regression (Bishop and Bishop, 2024, Sect. 5.4.3; Shalev-Shwartz and Ben-David, 2014, Sect. 9.3). Each summand is the negative of a logistic loss, so maximizing the log-likelihood and minimizing the average logistic loss are the same computation (Bishop, 2006, Sect. 4.3.2). For example, consider the classifier map $h$ learned by logistic regression from the days of $2024$ at Krems. Where its score is zero the sigmoid returns $1/2$, so the warning is issued exactly where the probability passes one half. A score of $0.907$ becomes a probability of $0.71$ for frost tomorrow, and a score of $-2.534$ becomes $0.07$.

Synonyms: logistic function.

See also: activation function, rectified linear unit, softmax function, logistic regression, linear model, classifier, probability, smooth.

References

  1. Bishop (2006). Pattern Recognition and Machine Learning. Springer Science+Business Media. doi.org/10.1007/978-0-387-45528-0
  2. Goodfellow et al. (2016). Deep Learning. MIT Press.
  3. Bishop and Bishop (2024). Deep Learning: Foundations and Concepts. Springer Nature. doi.org/10.1007/978-3-031-45468-4
  4. Shalev-Shwartz and Ben-David (2014). Understanding Machine Learning: From Theory to Algorithms. Cambridge Univ. Press. doi.org/10.1017/cbo9781107298019

Cite this entry

@misc{dictml_sigmoid,
  author = {Jung, Alexander},
  editor = {Olioumtsevits, Konstantina and Schnoor, Ekkehard},
  title = {sigmoid function},
  howpublished = {Dictionary of Applied Machine Learning (course edition)},
  year = {2026},
  doi = {10.5281/zenodo.21569296},
  note = {ISBN 978-952-64-3013-3, CC BY 4.0, retrieved 2026-11-26},
  url = {https://dictionaryofml.org/terms/sigmoid.html}
}