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.ops.ReLUV2.rst 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. mindspore.ops.ReLUV2
  2. ====================
  3. .. py:class:: mindspore.ops.ReLUV2(*args, **kwargs)
  4. 线性修正单元激活函数(Rectified Linear Unit activation function)。
  5. 按元素返回 :math:`\max(x,\ 0)` 。特别说明,负数输出值会被修改为0,正数输出不受影响。
  6. .. math::
  7. \text{ReLU}(x) = (x)^+ = \max(0, x),
  8. .. note::
  9. 与 `ReLu` 的区别在于该算子多输出一个mask,且算子的kernel与 `ReLu` 的不同。
  10. **输入:**
  11. - **input_x** (Tensor) - 输入Tensor必须是4-D Tensor。
  12. **输出:**
  13. - **output** (Tensor) - 数据类型和shape与 `input_x` 的相同。
  14. - **mask** (Tensor) - 数据类型必须为uint8的Tensor。
  15. **异常:**
  16. - **TypeError** - `input_x` 不是Tensor。
  17. - **ValueError** - `input_x` 的shape不是4-D。
  18. **支持平台:**
  19. ``Ascend``
  20. **样例:**
  21. >>> input_x = Tensor(np.array([[[[1, -2], [-3, 4]], [[-5, 6], [7, -8]]]]), mindspore.float32)
  22. >>> relu_v2 = ops.ReLUV2()
  23. >>> output, mask= relu_v2(input_x)
  24. >>> print(output)
  25. [[[[1. 0.]
  26. [0. 4.]]
  27. [[0. 6.]
  28. [7. 0.]]]]
  29. >>> print(mask)
  30. [[[[[1 0]
  31. [2 0]]
  32. [[2 0]
  33. [1 0]]]]]