softmax

dragon.nn.softmax(
  inputs,
  axis=-1,
  **kwargs
)[source]

Apply the softmax function.

The Softmax function is defined as:

\[\text{Softmax}(x) = \frac{e^{x_{i}}}{\sum e^{x_{j}}} \]

The argument axis could be negative:

x = dragon.ones((1, 4), dtype='float32')
print(dragon.nn.softmax(x, 1))   # [[0.25 0.25 0.25 0.25]]
print(dragon.nn.softmax(x, -1))  # Equivalent
Parameters:
  • inputs (dragon.Tensor) – The input tensor.
  • axis (int, optional, default=-1) – The axis to reduce.
Returns:

dragon.Tensor – The output tensor.