mindspore.mint.nn.Softmax

View Source On Gitee
class mindspore.mint.nn.Softmax(dim=None)[source]

Applies the Softmax function to an n-dimensional input Tensor.

For details, please refer to mindspore.mint.nn.functional.softmax().

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> from mindspore import Tensor, mint
>>> import numpy as np
>>> input = Tensor(np.array([-1, -2, 0, 2, 1]), mindspore.float16)
>>> softmax = mint.nn.Softmax()
>>> output = softmax(input)
>>> print(output)
[0.03168 0.01166 0.0861  0.636   0.2341 ]