log_softmax

Contents

log_softmax#

class brainstate.nn.log_softmax(x, axis=-1, where=None)[source]#

Log-Softmax function.

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 (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Input array.

  • axis (int | tuple[int, ...] | None) – The axis or axes along which the log-softmax should be computed. Either an integer or a tuple of integers. Default is -1.

  • where (Array | ndarray | bool | number | bool | int | float | complex | Quantity | None) – Elements to include in the log-softmax computation.

Returns:

An array with the same shape as the input.

Return type:

Array | Quantity

See also

softmax

The softmax function.