Stable Softmax
Return numerically stable softmax probabilities rounded to six decimals.
INTERACTIVE CONCEPT
See scores become probabilities
Adjust one logit to see how softmax redistributes probability across three values.
Subtracting the largest logit before exponentiation preserves the probabilities while reducing overflow risk.
Examples
EXAMPLE WALKTHROUGHequal
A guided view of the published example, not a trace of your code.
INPUT
[[0,0]]TASKstable_softmax()
EXPECTED OUTPUT
[0.5,0.5]Start with the input values shown in this example.
Example 1 of 2
Input: logits = [0,0]
Output: [0.5,0.5]
Explanation: equal
Input: logits = [1000,1000]
Output: [0.5,0.5]
Explanation: large logits
Hint 1
Subtract the maximum logit before exponentiation.