Stan Math Library
4.9.0
Automatic Differentiation
|
|
inline |
Return the softmax of the specified vector.
\( \mbox{softmax}(y) = \frac{\exp(y)} {\sum_{k=1}^K \exp(y_k)}, \)
The entries in the Jacobian of the softmax function are given by \( \begin{array}{l} \displaystyle \frac{\partial}{\partial y_m} \mbox{softmax}(y)[k] \\[8pt] \displaystyle \mbox{ } \ \ \ = \left\{ \begin{array}{ll} \mbox{softmax}(y)[k] \times (1 - \mbox{softmax}(y)[m]) & \mbox{ if } m = k, \mbox{ and} \\[6pt] -\mbox{softmax}(y)[k] \times \mbox{softmax}(y)[m] & \mbox{ if } m \neq k. \end{array} \right. \end{array} \)
ColVec | type of elements in the vector |
[in] | v | Vector to transform. |
Definition at line 47 of file softmax.hpp.