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.ReLU.rst 1.0 kB

1234567891011121314151617181920212223242526272829303132333435363738
  1. mindspore.nn.ReLU
  2. =================
  3. .. py:class:: mindspore.nn.ReLU
  4. 修正线性单元激活函数(Rectified Linear Unit activation function)。
  5. 按元素返回 :math:`\max(x,\ 0)` 。特别说明,负数输出值会被修改为0,正数输出不受影响。
  6. .. math::
  7. \text{ReLU}(x) = (x)^+ = \max(0, x),
  8. ReLU相关图参见 `ReLU <https://en.wikipedia.org/wiki/Activation_function#/media/File:Activation_rectified_linear.svg>`_ 。
  9. **输入:**
  10. - **x** (Tensor) - 用于计算ReLU的Tensor。数据类型为Number。shape为 :math:`(N,*)` ,其中 :math:`*` 表示任意的附加维度数。
  11. **输出:**
  12. Tensor,具有与 `x` 相同的数据类型和shape。
  13. **异常:**
  14. - **TypeError** - `x` 的数据类型不是Number。
  15. **支持平台:**
  16. ``Ascend`` ``GPU`` ``CPU``
  17. **样例:**
  18. >>> x = Tensor(np.array([-1, 2, -3, 2, -1]), mindspore.float16)
  19. >>> relu = nn.ReLU()
  20. >>> output = relu(x)
  21. >>> print(output)
  22. [0. 2. 0. 2. 0.]