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

50 lines
1.4 KiB
ReStructuredText
Raw Normal View History

2021-12-07 12:17:56 +08:00
mindspore.ops.Elu
=================
2021-12-21 18:09:08 +08:00
.. py:class:: mindspore.ops.Elu(alpha=1.0)
2021-12-07 12:17:56 +08:00
指数线性单元激活函数Exponential Linear Unit activation function
2021-12-07 12:17:56 +08:00
2021-12-21 18:09:08 +08:00
对输入的每个元素计算ELU。该激活函数定义如下
2021-12-07 12:17:56 +08:00
.. math::
\text{ELU}(x)= \left\{
\begin{array}{align}
\alpha(e^{x} - 1) & \text{if } x \le 0\\
x & \text{if } x \gt 0\\
\end{array}\right.
ELU相关图参见 `ELU <https://en.wikipedia.org/wiki/Activation_function#/media/File:Activation_elu.svg>`_
**参数:**
2021-12-21 18:09:08 +08:00
**alpha** (float)Elu的alpha值数据类型为浮点数。目前只支持alpha等于1.0默认值1.0。
2021-12-07 12:17:56 +08:00
**输入:**
2021-12-31 11:13:56 +08:00
**input_x** (Tensor) - 用于计算Elu的任意维度的Tensor数据类型为float16或float32。
2021-12-07 12:17:56 +08:00
**输出:**
Tensorshape和数据类型与 `x` 相同。
**异常:**
- **TypeError** - `alpha` 不是float。
- **TypeError** - `x` 的数据类型既不是float16也不是float32。
- **ValueError** - `alpha` 不等于1.0。
**支持平台:**
``Ascend`` ``GPU`` ``CPU``
**样例:**
>>> x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
>>> elu = ops.Elu()
>>> output = elu(x)
>>> print(output)
[[-0.63212055 4. -0.99966455]
[ 2. -0.99326205 9. ]]