You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.ELU.rst 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. mindspore.nn.ELU
  2. =================
  3. .. py:class:: mindspore.nn.ELU(alpha=1.0)
  4. 指数线性单元激活函数(Exponential Linear Uint activation function)。
  5. 对输入的每个元素计算ELU。该激活函数定义如下:
  6. .. math::
  7. E_{i} =
  8. \begin{cases}
  9. x, &\text{if } x \geq 0; \cr
  10. \text{alpha} * (\exp(x_i) - 1), &\text{otherwise.}
  11. \end{cases}
  12. ELU相关图参见 `ELU <https://en.wikipedia.org/wiki/Activation_function#/media/File:Activation_elu.svg>`_ 。
  13. **参数:**
  14. - **alpha** (`float`) – ELU的alpha值,数据类型为浮点数。默认值:1.0。
  15. **输入:**
  16. - **x** (Tensor) - 用于计算ELU的Tensor,数据类型为float16或float32。shape为 :math:`(N,*)` , :math:`*` 表示任意的附加维度数。
  17. **输出:**
  18. Tensor,具有与 `x` 相同的数据类型和shape。
  19. **异常:**
  20. - **TypeError** - `alpha` 不是浮点数。
  21. - **TypeError** - `x` 的数据类型既不是float16也不是float32。
  22. - **ValueError** - `alpha` 不等于1.0。
  23. **支持平台:**
  24. ``Ascend`` ``GPU`` ``CPU``
  25. **样例** :
  26. >>> x = Tensor(np.array([-1, -2, 0, 2, 1]), mindspore.float32)
  27. >>> elu = nn.ELU()
  28. >>> result = elu(x)
  29. >>> print(result)
  30. [-0.63212055 -0.86466473 0. 2. 1.]