mindspore.ops.csr_relu6

View Source On Gitee
mindspore.ops.csr_relu6(x: CSRTensor)[source]

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

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

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

Parameters

x (CSRTensor) – Input CSRTensor, with float16 or float32 data type.

Returns

CSRTensor, with the same dtype and shape as the x.

Raises
  • TypeError – If dtype of x is neither float16 nor float32.

  • TypeError – If x is not a CSRTensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> from mindspore import dtype as mstype
>>> from mindspore import Tensor, ops, CSRTensor
>>> indptr = Tensor([0, 1, 2, 2], dtype=mstype.int32)
>>> indices = Tensor([3, 0], dtype=mstype.int32)
>>> values = Tensor([-1, 2], dtype=mstype.float32)
>>> shape = (3, 4)
>>> x = CSRTensor(indptr, indices, values, shape)
>>> output = ops.csr_relu6(x)
>>> print(output.values)
[0. 2.]