jax.scipy.special.log_softmax#

jax.scipy.special.log_softmax(x, /, *, axis=None)[source]#

Log-Softmax function.

JAX implementation of scipy.special.log_softmax()

Computes the logarithm of the softmax function, which rescales elements to the range \([-\infty, 0)\).

\[\mathrm{log\_softmax}(x)_i = \log \left( \frac{\exp(x_i)}{\sum_j \exp(x_j)} \right)\]
Parameters:
  • x (ArrayLike) – input array

  • axis (int | tuple[int, ...] | None | None) – the axis or axes along which the log_softmax should be computed.

Returns:

An array of the same shape as x

Return type:

Array

Note

If any input values are +inf, the result will be all NaN: this reflects the fact that inf / inf is not well-defined in the context of floating-point math.

See also

softmax()