![]() |
Stan Math Library
5.3.0
Automatic Differentiation
|
|
inline |
Return the natural logarithm of the softmax of the specified vector, or of each vector in a container.
\( \log \mbox{softmax}(y) \ = \ y - \log \sum_{k=1}^K \exp(y_k) \ = \ y - \mbox{log\_sum\_exp}(y). \)
For the log softmax function, the entries in the Jacobian are \( \frac{\partial}{\partial y_m} \log\mbox{softmax}(y)[k] = \left\{ \begin{array}{ll} 1 - \mbox{softmax}(y)[m] & \mbox{ if } m = k, \mbox{ and} \\[6pt] -\mbox{softmax}(y)[m] & \mbox{ if } m \neq k. \end{array} \right. \)
| Container | type of input: an Eigen vector, std::vector of doubles, or nested container whose scalar type is arithmetic |
| [in] | x | vector or container of vectors to transform |
| std::domain_error | if any input vector is empty |
Definition at line 49 of file log_softmax.hpp.