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.LeakyReLU.rst 1.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. mindspore.nn.LeakyReLU
  2. =======================
  3. .. py:class:: mindspore.nn.LeakyReLU(alpha=0.2)
  4. Leaky ReLU激活函数。
  5. 该激活函数定义如下:
  6. .. math::
  7. \text{leaky_relu}(x) = \begin{cases}x, &\text{if } x \geq 0; \cr
  8. {\alpha} * x, &\text{otherwise.}\end{cases}
  9. 其中,:math:`\alpha` 表示 `alpha` 参数。
  10. 更多细节详见 `Rectifier Nonlinearities Improve Neural Network Acoustic Models <https://ai.stanford.edu/~amaas/papers/relu_hybrid_icml2013_final.pdf>`_。
  11. **参数:**
  12. **alpha** (`Union[int, float]`) – x<0时激活函数的斜率,默认值:0.2。
  13. **输入:**
  14. **x** (Tensor) - 计算LeakyReLU的任意维度的Tensor。
  15. **输出:**
  16. Tensor,数据类型和shape与 `x` 相同。
  17. **异常:**
  18. **TypeError** - `alpha` 不是浮点数或整数。
  19. **支持平台:**
  20. ``Ascend`` ``GPU`` ``CPU``
  21. **样例:**
  22. >>> x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
  23. >>> leaky_relu = nn.LeakyReLU()
  24. >>> output = leaky_relu(x)
  25. >>> print(output)
  26. [[-0.2 4. -1.6]
  27. [ 2. -1. 9. ]]