Softmax#

API#

class warp_nn.modules.activations.Softmax(*, dim: int = -1, requires_grad: bool = True)[source]#

Softmax activation function.

This class computes the Softmax activation function along the given dimension, rescaling the input values so that they lie in the range [0, 1] and sum to 1:

\[\text{Softmax}(x_i) = \frac{e^{x_i}}{\sum_j e^{x_j}}\]
Parameters:
  • dim – The dimension along which the Softmax function is computed.

  • requires_grad – Whether the cached output arrays of the module require gradients.

__call__(
input: array,
) → array[source]#

Forward pass of the activation function.

Parameters:

input – The input array.

Returns:

The output array, with same shape as the input array.

Raises:
  • IndexError – If the dimension is out of range for the input array.

  • TypeError – If the input array’s data type is not supported.

property dim: int[source]#

The dimension along which the function is computed.