mindspore.mint.nn.functional.relu6

View Source On Gitee
mindspore.mint.nn.functional.relu6(input, inplace=False)[source]

Computes ReLU (Rectified Linear Unit) upper bounded by 6 of input tensors element-wise.

\[\text{ReLU6}(input) = \min(\max(0,input), 6)\]

It returns \(\min(\max(0,input), 6)\) element-wise.

ReLU6 Activation Function Graph:

../../_images/ReLU6.png

Warning

This is an experimental optimizer API that is subject to change.

Parameters
  • input (Tensor) – input Tensor. Dtype is in int8, int16, int32, int64, uint8, float16, float32, bfloat16.

  • inplace (bool, optional) – Whether to apply erasing inplace. Default: False.

Returns

Tensor, with the same dtype and shape as the input.

Raises
  • TypeError – If input is not a Tensor.

  • TypeError – If dtype of input is not one of: int8, int16, int32, int64, uint8, float16, float32, bfloat16.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, mint
>>> x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
>>> result = mint.nn.functional.relu6(x)
>>> print(result)
[[0. 4. 0.]
 [2. 0. 6.]]