Log-Sum-Exp Trick: Softmax's Numerical Stability Secret

The exponential function in softmax can lead to numerical overflow or underflow with large or small input logits; the Log-Sum-Exp (LSE) trick mitigates this by subtracting the maximum logit before exponentiation, ensuring stable and accurate probability calculations.

Sources

Open the full topic