relu6

paddle.sparse.nn.functional. relu6 ( x, name=None ) [源代码]

稀疏 relu6 激活函数,要求 输入 xSparseCooTensorSparseCsrTensor

\[relu6(x) = min(max(0, x), 6)\]

其中,\(x\) 为输入的 Tensor。

参数

  • x (Tensor) - 输入的稀疏 Tensor,可以是 SparseCooTensor 或 SparseCsrTensor,数据类型为 float32、float64。

  • name (str,可选) - 具体用法请参见 Name,一般无需设置,默认值为 None。

返回

多维稀疏 Tensor, 数据类型和稀疏格式与 x 相同。

代码示例

>>> import paddle

>>> dense_x = paddle.to_tensor([-2., 0., 8.])
>>> sparse_x = dense_x.to_sparse_coo(1)
>>> out = paddle.sparse.nn.functional.relu6(sparse_x)