mindspore/docs/api/api_python/ops/mindspore.ops.func_softmax.rst

24 lines
1.0 KiB
ReStructuredText
Raw Normal View History

mindspore.ops.softmax
=====================
2022-08-16 15:30:10 +08:00
.. py:function:: mindspore.ops.softmax(x, axis=-1)
2022-12-29 16:33:21 +08:00
在指定轴上对输入Tensor执行Softmax激活函数做归一化操作。假设指定轴 :math:`x` 上有切片,那么每个元素 :math:`x_i` 所对应的Softmax函数如下所示
.. math::
\text{output}(x_i) = \frac{exp(x_i)}{\sum_{j = 0}^{N-1}\exp(x_j)},
其中 :math:`N` 代表Tensor的长度。
参数:
- **x** (Tensor) - Softmax的输入任意维度的Tensor。其数据类型为float16或float32。
2022-11-07 10:52:38 +08:00
- **axis** (Union[int, tuple[int]], 可选) - 指定Softmax操作的轴。默认值-1。
返回:
Tensor数据类型和shape与 `x` 相同。
异常:
2022-11-02 19:28:41 +08:00
- **TypeError** - `axis` 不是int或者tuple。
- **TypeError** - `x` 的数据类型既不是float16也不是float32。
- **ValueError** - `axis` 是长度小于1的tuple。
- **ValueError** - `axis` 是一个tuple其元素不全在[-len(x.shape), len(x.shape))范围中。