mindspore.ops.Softmax

查看源文件
class mindspore.ops.Softmax(axis=- 1)[源代码]

在指定轴上使用Softmax函数做归一化操作。

更多参考详见 mindspore.ops.softmax()

参数:
  • axis (Union[int, tuple],可选) - 指定Softmax操作的轴。默认值: -1

输入:
  • input (Tensor) - shape:\((N, *)\) ,其中 \(*\) 表示任意数量的附加维度。

输出:

Tensor,数据类型和shape与 input 相同。

支持平台:

Ascend GPU CPU

样例:

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