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?
1 Answer
$\begingroup$
$\endgroup$
2
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}} $
-
-
$\begingroup$ @Nicoinlas welcome to DSSE; please see What should I do when someone answers my question? $\endgroup$ Commented Feb 2, 2022 at 21:13