2
$\begingroup$

I was playing around with the softmax function and tried around with the numerical stability of softmax. If we increase the exponent in the numerator and denominator with the same value, the output of the softmax stays constant (see picture below where -Smax is added). I cannot figure out how to prove this numerical stability (although I read that it is true). Can anyone help me with the proof?

enter image description here

$\endgroup$

1 Answer 1

5
$\begingroup$

Take into accout that $e^{a-b} = e^a \cdot e^{-b}$, therefore:

$\dfrac{e^{s_{y_i} - s_{max}}}{\sum e^{s_k - s_{max}}} = \dfrac{e^{s_{y_i}} e^{- s_{max}}}{\sum e^{s_k} e^{- s_{max}}} = \dfrac{e^{s_{y_i}} e^{- s_{max}}}{e^{- s_{max}} \sum e^{s_k}} = \dfrac{e^{s_{y_i}}}{\sum e^{s_k}} $

$\endgroup$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.