softmax

Contents

softmax#

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

Softmax activation function.

Computes the function which rescales elements to the range \([0, 1]\) such that the elements along axis sum to \(1\).

\[\mathrm{softmax}(x) = \frac{\exp(x_i)}{\sum_j \exp(x_j)}\]
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 softmax should be computed. The softmax output summed across these dimensions should sum to \(1\). 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 softmax computation.

Returns:

An array with the same shape as the input.

Return type:

Array | Quantity

See also

log_softmax

Logarithm of the softmax function.

softmin

Softmin activation function.