mindspore2022/docs/api/api_python/nn/mindspore.nn.ELU.rst

48 lines
1.3 KiB
ReStructuredText
Raw 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.nn.ELU
=================
.. py:class:: mindspore.nn.ELU(alpha=1.0)
指数线性单元激活函数Exponential Linear Uint activation function
对输入的每个元素计算ELU。该激活函数定义如下
.. math::
E_{i} =
\begin{cases}
x, &\text{if } x \geq 0; \cr
\text{alpha} * (\exp(x_i) - 1), &\text{otherwise.}
\end{cases}
ELU相关图参见 `ELU <https://en.wikipedia.org/wiki/Activation_function#/media/File:Activation_elu.svg>`_
**参数:**
- **alpha** (`float`) ELU的alpha值数据类型为浮点数。默认值1.0。
**输入:**
- **x** Tensor - 用于计算ELU的Tensor数据类型为float16或float32。shape为 :math:`(N,*)` :math:`*` 表示任意的附加维度数。
**输出:**
Tensor具有与 `x` 相同的数据类型和shape。
**异常:**
- **TypeError** - `alpha` 不是浮点数。
- **TypeError** - `x` 的数据类型既不是float16也不是float32。
- **ValueError** - `alpha` 不等于1.0。
**支持平台:**
``Ascend`` ``GPU`` ``CPU``
**样例** :
>>> x = Tensor(np.array([-1, -2, 0, 2, 1]), mindspore.float32)
>>> elu = nn.ELU()
>>> result = elu(x)
>>> print(result)
[-0.63212055 -0.86466473 0. 2. 1.]