Logit vs Sigmoid: How the Sigmoid Turns Logits into Probabilities

What are logits? Raw, unbounded scores equal to the log-odds. The sigmoid turns them into probabilities, and softmax does the same for exclusive classes.

Logit vs Sigmoid: How the Sigmoid Turns Logits into Probabilities
Written by TechnoLynx Published on 11 Jul 2026

What are logits? Logits are the raw, unbounded scores a model produces before anything turns them into probabilities, and in a binary classifier a logit is the log-odds of the positive class. The sigmoid function, σ(z) = 1 / (1 + e^(−z)), maps that score into a probability between 0 and 1, and the logit function is its exact inverse. A logit of 0 therefore means a probability of 0.5, positive logits mean probabilities above 0.5 and negative logits mean probabilities below it.

The rest of this article is about reading logits correctly, choosing the right function to apply to them, and knowing why frameworks want them left raw.

Logits in a neural network: the score before any probability

In a neural network, a logit is the raw, unscaled output of a neuron in the last layer, taken before a sigmoid or softmax is applied. A logit can be any real number, large or small, positive or negative. A chest X-ray model with four outputs might hand back a vector such as [-0.5, 1.2, -0.1, 2.4], one raw value per finding, and those numbers mean nothing as probabilities until a function converts them.

The word carries two slightly different meanings, and it helps to keep them apart. In binary logistic regression, the logit is strictly the log-odds of the positive probability; in broader neural-network usage, “logits” usually just means the raw pre-activation scores, including the vectors used for multi-class classification. When someone says “the logits” of a ten-class computer vision image classifier, they mean the second sense: ten raw scores.

How do I read a logit value, and what does a logit of 0 mean?

Read a logit by its sign first and its size second. A logit of 0 sits exactly at the sigmoid’s midpoint, σ(0) = 0.5, which is why the usual binary decision rule predicts the positive class when the output exceeds 0.5. Positive logits push the probability above 0.5 and negative logits push it below.

Size matters because the logit is the logarithm of the odds. Converting a logit back into odds takes the exponential function, the inverse of the natural logarithm. So a logit of about 1.1 corresponds to odds of roughly 3 to 1 (e^1.1 ≈ 3.0), and odds of 3 to 1 are a probability of 0.75. Far from zero, the curve flattens: the Google Machine Learning Crash Course gives the example of a z value of −10 mapping to a probability of 0.00004.

This is also where logistic regression coefficients get their meaning. Each coefficient is the change in the logit for a one-unit change in its predictor, an additive effect on the log-odds rather than on the probability itself. Our explainer on logistic regression in machine learning covers the model fitting side of that in more depth.

How the sigmoid function turns logits into probabilities

The sigmoid, also called the logistic function, takes any real input and returns a value strictly between 0 and 1. As the input heads towards negative infinity the output approaches 0, and as it heads towards positive infinity the output approaches 1, but it never reaches either bound.

Because the output lives in (0, 1), it can be read as the parameter of a Bernoulli distribution: the probability that the label is 1, with the probability of 0 being one minus that. The function is also symmetric about the midpoint, so σ(−z) = 1 − σ(z). Flipping the sign of a logit swaps the probabilities of the two classes, which is a handy sanity check when debugging a classifier whose labels might be inverted.

Worked example: four logits through sigmoid and softmax

The table uses the raw output vector from the Glass Box Medicine chest X-ray example, with the probabilities that source reports for each transform.

Raw output (logit) Sigmoid probability Softmax probability
−0.5 0.37 0.04
1.2 0.77 0.21
−0.1 0.48 0.05
2.4 0.91 0.70
Sum 2.53 1.00

The sigmoid column sums to 2.53 because the sigmoid looks at each raw value on its own, while the softmax column always sums to 1 because every output shares a common denominator. The highest logit gets the highest probability under either transform. What changes is the meaning: four independent yes-or-no judgements in one column, one distribution over four competing answers in the other.

Is the logit function the inverse of the sigmoid, and what are log-odds?

Yes, exactly. The logit of a probability p is ln(p / (1 − p)), the natural logarithm of the odds, which is why the logit is also called the log-odds. The logit maps a probability from the interval (0, 1) onto the whole real line, and the sigmoid maps it back. SciPy names this pair directly: its expit function is the logistic sigmoid, defined as 1/(1+exp(-x)), and is documented as the inverse of the logit function.

Statistics reaches the same relationship from the other direction. A logistic (or logit) model treats the log-odds of an event as a linear combination of the input variables. Unbounding the probability is the point: the logit converts a quantity confined to (0, 1) into one ranging over (−∞, +∞), matching the range of a linear prediction function. The logistic function then converts log-odds back into a probability, which is where the model gets its name, and the unit of the log-odds scale is itself called a logit, from “logistic unit”.

There is a probabilistic reading too. The logistic function is the cumulative distribution function of the standard logistic distribution, so the logit is that distribution’s quantile function.

Why do models output raw logits instead of probabilities during training?

During training, PyTorch’s BCEWithLogitsLoss and CrossEntropyLoss take raw logits and do the probability step internally, more stably than a separate sigmoid would. Logits also give the model an unconstrained output space, whereas probabilities must stay between 0 and 1 and, in a multi-class setting, sum to 1.

The framework APIs encode this as a contract:

  • PyTorch’s BCEWithLogitsLoss combines a sigmoid layer and binary cross-entropy in one class, and the PyTorch 2.14 documentation states it is more numerically stable than a plain sigmoid followed by BCELoss because the combined form can use the log-sum-exp trick.
  • PyTorch’s CrossEntropyLoss expects unnormalised logits for each class, which need not be positive or sum to 1, and is equivalent to LogSoftmax followed by NLLLoss.
  • TensorFlow’s tf.nn.sigmoid_cross_entropy_with_logits measures the probability error for outcomes that are independent, including ordinary binary classification with 0-or-1 labels.

The reason this matters mathematically goes back to saturation. Goodfellow, Bengio and Courville note that sigmoid output units work with gradient-based learning when an appropriate cost function undoes the sigmoid’s saturation. With sigmoid plus binary cross-entropy, or softmax plus categorical cross-entropy, the gradient with respect to the logits reduces to p̂ − y, which avoids the saturation you would get from pairing a sigmoid with squared error.

The practical consequence is easy to get wrong. Passing softmax probabilities into a loss that expects logits changes the calculation, so outputs have to be labelled correctly and the probability transform applied only where the library expects it. To read raw logits from a trained model that ends in a sigmoid, the Taxlifier authors drop that final layer after training.

When the question becomes how those numerics behave on a different runtime, our article on what sigmoid numerics mean for a serving-path port picks it up.

Sigmoid or softmax on the logits?

Apply sigmoid when each output is its own yes-or-no question, and softmax when the classes are mutually exclusive and exactly one is right. Sigmoid covers binary classification with one output unit, and multi-label classification with K output units each carrying its own sigmoid, where the probabilities are independent and an example can belong to several labels. Softmax normalises a vector of K logits into one categorical distribution whose components are non-negative and sum to 1.

Situation Function on the logits What the outputs mean Matching loss
Binary classification Sigmoid on one logit Probability of the positive class Binary cross-entropy
Multi-label (several labels can be true) Sigmoid on each logit separately Independent probabilities, no need to sum to 1 Binary cross-entropy per label
Multi-class (exactly one label is true) Softmax across all logits A distribution that sums to 1 Categorical cross-entropy

A multi-label image tagger can give high sigmoid probabilities to both “beach” and “sunset”, while a single-label animal classifier using softmax has to divide its probability across bird, cat and dog.

The two are less different than the table suggests. For two classes, the softmax probability of class 1 works out to σ(z₁ − z₀), the sigmoid of the difference between the logits, so binary logistic regression is multinomial logistic regression with K = 2 and one logit fixed at zero as the reference. That identity also explains why softmax logits are not log-odds one by one: only their differences carry meaning. One practical note on softmax itself: subtracting the maximum logit before exponentiating leaves the probabilities unchanged and avoids overflow.

What are logits in a large language model?

In a large language model, the logits are one real-valued score per vocabulary token, produced by the final linear projection at each position before any normalisation. Softmax turns them into token probabilities, and the decoding settings then pick or sample the next token from that distribution. Softmax acts as a non-linear amplifier, so small gaps in logit space become large gaps in probability, though the highest-logit token always keeps the highest probability.

Several generation controls work directly on these logits, before the softmax:

  • Temperature scaling divides the logits by a temperature, where a lower value sharpens the distribution and a higher one flattens it.
  • Logit bias adds a constant to specific tokens’ logits to push generation towards or away from them.
  • Token masking sets forbidden tokens’ logits to negative infinity so they get zero probability, which is how constrained decoding such as JSON mode works.
  • Top-k and top-p sampling keep only a subset of high-logit tokens before normalising.

Training runs in logit space too: transformer training loops compute cross-entropy directly from the logits and the target token id, using the log-sum-exp trick for stability.

A calibration survey also describes temperature scaling of logits as a way to soften predictions so a model is neither overconfident nor underconfident.

FAQ

What is the difference between logit and logistic?

The logit maps a probability to log-odds, and the logistic function maps log-odds back to a probability; they are inverses of each other. The logistic function is also called the sigmoid or expit.

Which function is used in logistic regression?

Logistic regression uses the logit as its link function, fitting the log-odds of success as a linear function of the predictors. The sigmoid (logistic) function then turns that linear score into a predicted probability restricted to (0, 1).

Which is better, logit or probit?

They differ in the distribution behind them: the logit is the quantile function of the logistic distribution and the probit is the quantile function of the normal distribution.

Back See Blogs
arrow icon