mindspore/docs/api/api_python/mint/mindspore.mint.nn.functiona...

23 lines
1.0 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.mint.nn.functional.softmax
====================================
.. py:function:: mindspore.mint.nn.functional.softmax(input, dim=None, dtype=None)
在指定轴上对输入Tensor执行Softmax激活函数做归一化操作。假设指定轴 :math:`dim` 上有切片,那么每个元素 :math:`input_i` 所对应的Softmax函数如下所示
.. math::
\text{output}(input_i) = \frac{\exp(input_i)}{\sum_{j = 0}^{N-1}\exp(input_j)},
其中 :math:`N` 代表Tensor的长度。
参数:
- **input** (Tensor) - Tensorshape为 :math:`(N, *)` ,其中 :math:`*` 为任意额外维度。
- **dim** (int可选) - 指定Softmax操作的轴。默认值 ``None``
- **dtype** (:class:`mindspore.dtype`, 可选) - 如果设置此参数,则会在执行之前将 `input` 转换为指定的类型返回的Tensor类型也将为指定类型 `dtype`。默认值: ``None``
返回:
Tensor数据类型和shape与 `input` 相同。
异常:
- **TypeError** - `dim` 不是int。