Softmax Calculator

Convert a list of numerical scores, logits, or model outputs into probabilities with this free online softmax calculator. Adjust the temperature to control how concentrated or evenly distributed the resulting probabilities are.

Calculate Softmax Probabilities

Enter at least two numerical values. Separate them with commas, spaces, semicolons, or new lines.

Must be greater than zero. Use 1 for standard softmax.

2.0, 1.0, 0.1

Try the example or enter your own values.

What Is the Softmax Function?

The softmax function converts a vector of real-valued numbers into a probability distribution. It is widely used in machine learning, neural networks, classification models, and artificial intelligence.

Each output probability is between zero and one, and all the probabilities add up to one. Larger input scores generally receive larger probabilities.

Softmax Formula

softmax(z)i = exp(zi) / Σj=1K exp(zj)

Where:

Softmax with Temperature

softmax(z)i = exp(zi / T) / Σj=1K exp(zj / T)

Temperature (T) controls the shape of the probability distribution. The standard softmax function uses T = 1.

How Temperature Changes Softmax

Low Temperature (T less than 1)

A lower temperature makes the probability distribution sharper. The largest input score tends to receive a higher probability, while the other probabilities become smaller.

Standard Temperature (T = 1)

A temperature of 1 produces the ordinary softmax function without additional temperature scaling.

High Temperature (T greater than 1)

A higher temperature makes the probability distribution more uniform. Differences between the resulting probabilities become less pronounced.

T → 0⁺ : distribution becomes concentrated on the largest score
T = 1 : standard softmax
T → ∞ : probabilities approach 1/K for each of K values

Worked Softmax Example

Consider the input vector:

z = [2.0, 1.0, 0.1]

First, calculate the exponential of each value:

exp(2.0) ≈ 7.3891
exp(1.0) ≈ 2.7183
exp(0.1) ≈ 1.1052

Next, calculate the sum:

7.3891 + 2.7183 + 1.1052 ≈ 11.2126

Divide each exponential by the total:

softmax(2.0) ≈ 7.3891 / 11.2126 ≈ 0.6590
softmax(1.0) ≈ 2.7183 / 11.2126 ≈ 0.2424
softmax(0.1) ≈ 1.1052 / 11.2126 ≈ 0.0986

The resulting probabilities are approximately:

[0.6590, 0.2424, 0.0986]

The probabilities add up to approximately 1.0000.

Why Is Numerical Stability Important?

The exponential function grows very quickly. Applying exp() directly to large input values can cause numerical overflow in computer calculations.

A common stable implementation subtracts the maximum input value before calculating exponentials:

softmax(z)i = exp(zi - max(z)) / Σ exp(zj - max(z))

This transformation does not change the softmax result because the same positive scaling factor is applied to every exponential. It reduces the risk of overflow and is used by this calculator.

Applications of Softmax

Frequently Asked Questions

1. What does the softmax function calculate?

Softmax converts a vector of real-valued scores into a probability distribution. Every output is between zero and one, and the outputs sum to one.

2. What is the softmax formula?

The probability for an input value is its exponential divided by the sum of the exponentials of all input values: exp(zᵢ) / Σ exp(zⱼ).

3. Do softmax probabilities always add up to one?

Yes. In exact arithmetic, the probabilities sum to one. Small differences in displayed results can occur because of floating-point precision and rounding.

4. Can softmax handle negative numbers?

Yes. Softmax accepts positive numbers, negative numbers, and zero. It can be applied to any finite real-valued input vector.

5. What happens when temperature is reduced?

Reducing temperature generally makes the distribution sharper, increasing the probability assigned to the largest score relative to the other scores.

6. What happens when temperature is increased?

Increasing temperature makes the distribution more uniform. As temperature approaches infinity, each probability approaches 1 divided by the number of input values.

7. Why subtract the maximum value before exponentiation?

Subtracting the maximum is a numerical stability technique. It prevents unnecessarily large exponentials while preserving the mathematical softmax probabilities.

8. Is softmax the same as sigmoid?

No. Sigmoid independently maps a value to a number between zero and one. Softmax operates on a group of values together and normalizes them into a probability distribution.

9. How many values can I calculate?

This calculator supports between 2 and 500 finite numerical input values.

Related Calculators