mindspore.ops.Softmax

class mindspore.ops.Softmax(axis=- 1)[source]

Applies the Softmax operation to the input tensor on the specified axis.

Refer to mindspore.ops.softmax() for more details.

Parameters

axis (Union[int, tuple]) – The axis to perform the Softmax operation. Default: -1 .

Inputs:
  • logits (Tensor) - Tensor of shape \((N, *)\), where \(*\) means, any number of additional dimensions, with float16, float32 or float64(CPU, GPU) data type.

Outputs:

Tensor, with the same type and shape as the logits.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> logits = Tensor(np.array([1, 2, 3, 4, 5]), mindspore.float32)
>>> softmax = ops.Softmax()
>>> output = softmax(logits)
>>> print(output)
[0.01165623 0.03168492 0.08612854 0.23412167 0.6364086 ]