Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ inverse_softmax()

template<typename Vector , require_vector_t< Vector > * = nullptr>
void stan::math::inverse_softmax ( const Vector &  simplex,
Vector &  y 
)

Writes the inverse softmax of the simplex argument into the second argument.

See softmax for the inverse function and a definition of the relation.

The inverse softmax function is defined by

\(\mbox{inverse\_softmax}(x)[i] = \log x[i]\).

This function defines the inverse of softmax up to a scaling factor.

Because of the definition, values of 0.0 in the simplex are converted to negative infinity, and values of 1.0 are converted to 0.0.

There is no check that the input vector is a valid simplex vector.

Template Parameters
Vectortype of the simplex vector
Parameters
simplexSimplex vector input.
yVector into which the inverse softmax is written.
Exceptions
std::invalid_argumentif size of the input and output vectors differ.

Definition at line 37 of file inverse_softmax.hpp.