mindspore.ops.coo_relu6
- mindspore.ops.coo_relu6(x)[源代码]
- 对输入的COOTensor逐元素计算其应用ReLU激活函数后的值,上限为6。 \[\text{ReLU6}(x) = \min(\max(0,x), 6)\]- 返回 \(\min(\max(0,x), 6)\) 元素的值。 - 参数:
- x (COOTensor) - coo_relu6的输入,数据类型为float16或float32。 
 
- 返回:
- COOTensor,数据类型和shape与 x 相同。 
- 异常:
- TypeError - 如果 x 的数据类型既不是float16也不是float32。 
- TypeError - 如果 x 不是COOTensor。 
 
- 支持平台:
- Ascend- GPU- CPU
 - 样例: - >>> from mindspore import dtype as mstype >>> from mindspore import Tensor, ops, COOTensor >>> 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.]