Softmax Calculator
Convert logits to probabilities using the softmax function.
Softmax Input
softmax(x_i) = e^(x_i/T) / sum(e^(x_j/T))
T < 1: sharper distribution | T > 1: smoother distribution
Temperature Effects
- - T = 1.0: Standard softmax
- - T < 1.0: More confident predictions
- - T > 1.0: More uniform distribution
- - T → 0: Approaches argmax
Predicted Class
Class 0
65.90% confidence
Probability Distribution
What the Softmax Calculator Does
The softmax calculator converts a vector of raw neural network scores — called logits — into a clean probability distribution that sums to exactly 1. You paste a comma-separated list of logits such as 2.0, 1.0, 0.1, optionally set a temperature, and the tool instantly returns the probability for every class, the predicted class (the one with the highest probability), the percentage confidence, and the entropy of the distribution in bits. It is the exact computation that sits at the output of nearly every classification network, transformer language model, and reinforcement learning policy.
Logits are the unnormalized outputs of the final linear layer. On their own they can be any real number — positive, negative, large, or small — and they do not add up to anything meaningful. The softmax function fixes that by exponentiating each logit and dividing by the sum of all exponentials. Because the exponential is always positive and the values are normalized by their total, every output lands in the open interval (0, 1) and the whole vector sums to 1, which is precisely what a probability distribution requires.
This softmax calculator also exposes temperature scaling, a single knob that controls how sharp or smooth the resulting distribution is. A temperature below 1 makes the model more confident (the largest logit dominates), while a temperature above 1 flattens the distribution toward uniform. Temperature is the same parameter you adjust when you tune the "creativity" of a large language model during text generation. By reporting probabilities, the predicted class, and entropy together, the tool lets you build intuition for how logits, temperature, and confidence interact — whether you are debugging a classifier, studying for a machine learning exam, or tuning sampling for an LLM.
The Softmax Formula with Temperature
The softmax function for class i divides the exponential of that class's temperature-scaled logit by the sum of the exponentials of every class. The temperature T simply divides each logit before exponentiation. This calculator implements exactly that formula in JavaScript, including the standard numerical-stability trick of subtracting the maximum scaled logit before exponentiating — a shift that never changes the result because it cancels in the numerator and denominator, but it prevents overflow when logits are large.
Walking through the steps the code performs: first each logit x is divided by the temperature to give a scaled logit x/T. Then the maximum scaled value is subtracted from every entry for stability. Each shifted value is passed through the exponential function. Those exponentials are summed, and each exponential is divided by that sum to produce a probability. The class with the largest probability is reported as the predicted class, and its probability times 100 is the confidence percentage.
Alongside the probabilities, the tool computes entropy using base-2 logarithms, so the result is expressed in bits. Entropy measures how spread out the distribution is: a perfectly confident one-hot prediction has zero entropy, while a uniform distribution over n classes has the maximum possible entropy of log₂(n) bits. Low entropy means the model is sure about a single class; high entropy means it is hedging across several. Watching entropy change as you adjust temperature is one of the fastest ways to feel what temperature scaling actually does to a model's confidence.
Softmax with Temperature Scaling
Where:
- x_i= The logit (raw score) for class i, before normalization
- T= The temperature; T < 1 sharpens the distribution, T > 1 smooths it, T = 1 is standard softmax
- e= Euler's number, approximately 2.71828, the base of the natural exponential
- sum_j= The sum over all classes j of the exponentiated, temperature-scaled logits (the normalization constant)
How Temperature Scaling Changes the Distribution
Temperature scaling is the most important control in this softmax calculator after the logits themselves. Dividing every logit by T before exponentiation rescales the gaps between scores. Because the exponential amplifies differences, shrinking those gaps (large T) flattens the output toward a uniform distribution, while widening them (small T) pushes probability mass onto the single highest logit.
Consider the default logits 2.0, 1.0, 0.1. At the standard temperature of T = 1.0, the softmax probabilities are roughly 65.90%, 24.24%, and 9.86%. Lower the temperature to T = 0.5 and the same logits produce a much sharper distribution of about 86.38%, 11.69%, and 1.93% — the top class becomes far more dominant. Raise it to T = 2.0 and the distribution smooths to about 50.17%, 30.43%, and 19.40%, much closer to uniform. The logits never changed; only the temperature did.
This behavior maps directly onto two practical regimes. In large language model sampling, a low temperature (for example 0.2) makes generation focused and deterministic — the model almost always picks its top token — while a high temperature (for example 1.2) makes it diverse and creative at the cost of coherence. In knowledge distillation, a high temperature is applied to a teacher network's logits so the "soft targets" reveal the relative similarities between classes (the so-called dark knowledge), which a student model learns from far more efficiently than from hard one-hot labels. As T approaches 0 the distribution collapses toward a one-hot argmax, and as T grows large it approaches a uniform distribution over all classes. Use the temperature field in this calculator to reproduce all three regimes and watch both the probabilities and the entropy respond.
Reading Predicted Class, Confidence, and Entropy
This softmax calculator surfaces three summary metrics on top of the raw probabilities, and each answers a different question. The predicted class is simply the index of the largest probability — the model's single best guess. Note that indexing is zero-based, so for the input 2.0, 1.0, 0.1 the predicted class is Class 0, the first value, because it carries the highest logit and therefore the highest probability.
The confidence is that winning probability expressed as a percentage. A confidence of 65.90% means the model assigns about two-thirds of the total probability mass to its top class. High confidence is not always reliable — neural networks are famously prone to being overconfident, which is exactly why temperature scaling is also used after training as a calibration technique to make reported confidences match real-world accuracy.
The entropy, reported in bits, captures uncertainty across the whole distribution rather than just the top class. The calculator computes it as the negative sum of each probability times its base-2 logarithm. The table below shows how entropy responds to temperature for the default logits, illustrating that smoother distributions carry more entropy.
| Temperature | Top Probability | Entropy (bits) | Character |
|---|---|---|---|
| T = 0.5 | 86.38% | 0.6545 | Sharp, confident |
| T = 1.0 | 65.90% | 1.2216 | Standard softmax |
| T = 2.0 | 50.17% | 1.4806 | Smooth, uncertain |
For three classes, the maximum possible entropy is log₂(3) ≈ 1.585 bits, reached only when all three probabilities are equal at 33.33%. The T = 2.0 row sits at 1.4806 bits, already close to that ceiling, which confirms the distribution is approaching uniform. Reading these three numbers together gives you a complete picture of both what the model predicts and how sure it is.
How to Use the Softmax Calculator
Using this softmax calculator takes two inputs. First, type or paste your logits into the text box as a comma-separated list, for example 2.0, 1.0, 0.1. These are the raw scores from the final layer of your network; they can be any real numbers including negatives, and you can enter as many classes as you like. The calculator parses the list, ignores blank or invalid entries, and treats the position of each value as its class index starting from zero.
Second, set the temperature. Leave it at 1.0 for a standard softmax, drop it below 1 to sharpen the distribution toward the top class, or raise it above 1 to smooth the distribution toward uniform. The temperature must be greater than zero; the field enforces a small minimum to avoid dividing by zero. As soon as you change either input, the results update with no button press required.
The output panel reports the predicted class and its confidence percentage prominently, then lists the entropy in bits and the number of classes. Below that, a probability distribution shows a labeled bar for every class with its exact probability and percentage, and the predicted class is highlighted. This makes the tool ideal for students checking hand-computed softmax values, engineers debugging a classifier's output, and anyone tuning LLM sampling temperature. Because every number here is produced by the same exponentiate-and-normalize formula used inside PyTorch, TensorFlow, and JAX, the results are reproducible and match what real frameworks compute.
Worked Examples
Standard Softmax of Three Logits
Problem:
Convert the logits 2.0, 1.0, 0.1 into probabilities using the standard temperature T = 1.0.
Solution Steps:
- 1With T = 1.0 the scaled logits are unchanged: 2.0, 1.0, 0.1. Exponentiate each: e^2.0 = 7.3891, e^1.0 = 2.7183, e^0.1 = 1.1052.
- 2Sum the exponentials: 7.3891 + 2.7183 + 1.1052 = 11.2125.
- 3Divide each exponential by the sum: 7.3891/11.2125 = 0.6590, 2.7183/11.2125 = 0.2424, 1.1052/11.2125 = 0.0986.
- 4The largest probability is 0.6590, so the predicted class is Class 0 with 65.90% confidence.
Result:
Probabilities: 65.90%, 24.24%, 9.86%. Predicted class: Class 0. Entropy: 1.2216 bits.
Sharpening with Low Temperature
Problem:
Take the same logits 2.0, 1.0, 0.1 but apply a low temperature of T = 0.5 to make the model more confident.
Solution Steps:
- 1Divide each logit by T = 0.5 to get scaled logits 4.0, 2.0, 0.2.
- 2Exponentiate: e^4.0 = 54.5982, e^2.0 = 7.3891, e^0.2 = 1.2214. Sum = 63.2086.
- 3Normalize: 54.5982/63.2086 = 0.8638, 7.3891/63.2086 = 0.1169, 1.2214/63.2086 = 0.0193.
- 4The top class now holds 86.38% versus 65.90% at T = 1.0, and entropy drops from 1.2216 to 0.6545 bits.
Result:
Probabilities: 86.38%, 11.69%, 1.93%. Predicted class: Class 0 with 86.38% confidence. The lower temperature sharpened the distribution.
Smoothing with High Temperature
Problem:
Use the logits 2.0, 1.0, 0.1 with a high temperature of T = 2.0 to flatten the distribution toward uniform.
Solution Steps:
- 1Divide each logit by T = 2.0 to get scaled logits 1.0, 0.5, 0.05.
- 2Exponentiate: e^1.0 = 2.7183, e^0.5 = 1.6487, e^0.05 = 1.0513. Sum = 5.4183.
- 3Normalize: 2.7183/5.4183 = 0.5017, 1.6487/5.4183 = 0.3043, 1.0513/5.4183 = 0.1940.
- 4Entropy rises to 1.4806 bits, close to the three-class maximum of log2(3) = 1.585 bits, confirming a smoother, less certain distribution.
Result:
Probabilities: 50.17%, 30.43%, 19.40%. Predicted class: Class 0 with only 50.17% confidence. Entropy: 1.4806 bits.
Binary Logits for Two Classes
Problem:
Compute softmax probabilities for two logits 3.0 and 1.0 at the standard temperature T = 1.0.
Solution Steps:
- 1Exponentiate the logits: e^3.0 = 20.0855 and e^1.0 = 2.7183.
- 2Sum the exponentials: 20.0855 + 2.7183 = 22.8038.
- 3Normalize: 20.0855/22.8038 = 0.8808 and 2.7183/22.8038 = 0.1192.
- 4The predicted class is Class 0 with 88.08% confidence; entropy is 0.5271 bits.
Result:
Probabilities: 88.08%, 11.92%. Predicted class: Class 0. Entropy: 0.5271 bits.
Tips & Best Practices
- ✓Use temperature T = 1.0 for a standard softmax; only change it when you specifically want to calibrate confidence or tune sampling diversity.
- ✓Lower the temperature below 1 to sharpen predictions and raise it above 1 to soften them toward a uniform distribution.
- ✓Remember that class indexing is zero-based, so the first logit you enter corresponds to Class 0.
- ✓Softmax is shift-invariant: adding the same constant to every logit leaves the output probabilities unchanged.
- ✓Watch the entropy value to gauge uncertainty; near-zero entropy means a confident prediction, while entropy close to log2(n) means the model is unsure.
- ✓Softmax is not scale-invariant: multiplying all logits by a constant is equivalent to changing the temperature and will change the probabilities.
- ✓For knowledge distillation, raise the teacher's temperature so the soft targets expose relative class similarities the student can learn from.
- ✓If you only have two classes, a softmax over the two logits gives the same result as a sigmoid applied to their difference.
Frequently Asked Questions
Sources & References
Last updated: 2026-06-05
Help us improve!
How would you rate the Softmax Calculator?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: Standard Mathematical References
by Various