megengine.functional.nn.softmax

softmax(inp, axis=None)[源代码]

Applies a \(\text{softmax}(x)\) function.

更多细节见 Softmax

实际案例

>>> import numpy as np
>>> x = Tensor(np.arange(-5, 5, dtype=np.float32)).reshape(2,5)
>>> out = F.softmax(x)
>>> out.numpy().round(decimals=4)
array([[0.0117, 0.0317, 0.0861, 0.2341, 0.6364],
       [0.0117, 0.0317, 0.0861, 0.2341, 0.6364]], dtype=float32)
返回类型

Tensor