mindspore.ops.coo_relu6

mindspore.ops.coo_relu6(x: COOTensor)[source]

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

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

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

Parameters

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

Returns

COOTensor, 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 COOTensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> indices = Tensor([[0, 1], [1, 2]], dtype=mstype.int64)
>>> values = Tensor([-1, 2], dtype=mstype.float32)
>>> shape = (3, 4)
>>> x = COOTensor(indices, values, shape)
>>> output = ops.coo_relu6(x)
>>> print(output.values)
[0. 2.]