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.3 kB

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