Web Simulation 

 

 

 

 

SoftMax 

This interactive simulation visualizes the SoftMax function used in classification. You adjust raw logits and a temperature parameter, watch them become probabilities, and pick a true class to highlight in the formula breakdown.

 

Math behind the Simulation

1. The pipeline

SoftMax turns unconstrained logits z1, …, zn into probabilities that sum to 1:

Pi = ezi/T / ∑j ezj/T.

Stage 1: Logits — raw scores (any sign). Stage 2: Exponentiation — ez/T makes values positive and exaggerates differences. Stage 3: Normalization — divide by the sum so probabilities add to 1.

2. Temperature T

Low T sharpens the distribution (almost one-hot); high T softens it toward uniform. T appears in the exponent: zi/T.

3. True class

Use the True radio under each probability bar to select which class to highlight. The formula breakdown shows Pi for that class.

Formula: Pi = ezi/T / ∑j ezj/T

1.0

Logits (z)

z₀
2.00
z₁
1.00
z₂
0.10
z₃
-1.00
→ Exp →

ez/T

0
0
0
0
→ Normalize →

Probability (P)

0%
0%
0%
0%
P0 = e^2 / (e^2 + …) = 0.00

 

Usage

Follow these steps to explore the SoftMax pipeline:

  1. Logits (z): Use the four sliders to set raw scores (range −5 to +5). Watch Stage 2 (exponentiation) and Stage 3 (probabilities) update in real time.
  2. Temperature (T): Lower T sharpens the distribution (almost one-hot); higher T softens it. Adjust the T slider and observe the effect on the orange and green bars.
  3. True Class: Select which class to highlight using the True radio under each probability bar. The formula breakdown shows Pi for the selected class.

Tips: Try low T (e.g. 0.2) vs high T (e.g. 3) to compare sharp vs soft distributions. The exponentiation (ez/T) bars use a dynamic scale: the tallest bar is always 100%, so no clipping; relative heights show the true ratios even when values differ by orders of magnitude.

Parameters

  • Logits z0…z3: Raw scores, range −5 to +5. Defaults 2, 1, 0.1, −1.
  • Temperature T: Scale in the exponent (0.1–5). Default 1. Low T → near one-hot; high T → near uniform.
  • True Class: Index of the class to highlight (0–3); used in the formula breakdown.
  • Exponentiation (ez/T) chart: Bar heights scale to the current maximum (tallest = 100%); no clipping. Numeric labels show raw values.