mindspore.ops.ReLU6
- class mindspore.ops.ReLU6[source]
Computes ReLU (Rectified Linear Unit) upper bounded by 6 of input tensors element-wise.
\[\text{ReLU6}(x) = \min(\max(0,x), 6)\]It returns \(\min(\max(0,x), 6)\) element-wise.
- Inputs:
input_x (Tensor) - Tensor of shape \((N, *)\), where \(*\) means, any number of additional dimensions, with float16 or float32 data type.
- Outputs:
Tensor, with the same type and shape as the input_x.
- Raises
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> input_x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32) >>> relu6 = ops.ReLU6() >>> result = relu6(input_x) >>> print(result) [[0. 4. 0.] [2. 0. 6.]]