mindspore/docs/api/api_python/nn/mindspore.nn.LogSoftmax.rst

33 lines
995 B
ReStructuredText
Raw Normal View History

2021-12-08 15:50:20 +08:00
mindspore.nn.LogSoftmax
=============================
.. py:class:: mindspore.nn.LogSoftmax(axis=-1)
Log Softmax激活函数。
按元素计算Log Softmax激活函数。
输入经Softmax函数、Log函数转换后值的范围在[-inf,0)。
Log Softmax定义如下
.. math::
\text{logsoftmax}(x_i) = \log \left(\frac{\exp(x_i)}{\sum_{j=0}^{n-1} \exp(x_j)}\right),
其中,:math:`x_i` 是输入Tensor的一个元素。
2022-07-22 16:25:38 +08:00
参数:
- **axis** (int) - Log Softmax运算的axis-1表示最后一个维度。默认值-1。
2021-12-08 15:50:20 +08:00
2022-07-22 16:25:38 +08:00
输入:
- **x** (Tensor) - Log Softmax的输入数据类型为float16或float32。
2021-12-08 15:50:20 +08:00
2022-07-22 16:25:38 +08:00
输出:
Tensor数据类型和shape与 `x` 相同,输出值的范围在[-inf,0)。
2021-12-08 15:50:20 +08:00
2022-07-22 16:25:38 +08:00
异常:
- **TypeError** - `axis` 不是int。
- **TypeError** - `x` 的数据类型既不是float16也不是float32。
- **ValueError** - `axis` 不在[-len(x), len(x))范围中。