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.- Inputs:
logits (Tensor) - Tensor of shape \((N, *)\), where \(*\) means, any number of additional dimensions. Supported dtypes:
Ascend: float16, float32.
GPU/CPU: float16, float32, float64.
- 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 ]