mindspore.nn.ReLU
- class mindspore.nn.ReLU[源代码]
逐元素计算ReLU(修正线性单元)激活函数。
\[\text{ReLU}(input) = (input)^+ = \max(0, input),\]逐元素求 \(\max(0, input)\) 。
说明
输出为负的神经元会被抑制,正值保持不变。
ReLU激活函数图:
- 输入:
input (Tensor) - 输入 tensor。
- 输出:
Tensor。
- 支持平台:
AscendGPUCPU
样例:
>>> import mindspore >>> relu = mindspore.nn.ReLU() >>> input_tensor = mindspore.tensor([-1.0, 2.0, -3.0, 2.0, -1.0], mindspore.float32) >>> output = relu(input_tensor) >>> print(output) [0. 2. 0. 2. 0.]