mindspore.ops.Softmax

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

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

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

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

输入:
  • logits (Tensor) - shape:\((N, *)\) ,其中 \(*\) 表示任意数量的附加维度。其数据类型为float16或float32。

输出:

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

支持平台:

Ascend GPU CPU

样例:

>>> 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 ]