relu

paddle.sparse.functional. relu ( x, name=None ) [source]

sparse relu activation.

\[out = max(x, 0)\]
Parameters
  • x (Tensor) – The input Sparse Tensor with data type float32, float64.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

A Sparse Tensor with the same data type and shape as x .

Examples

import paddle
import numpy as np
from paddle.fluid.framework import _test_eager_guard

with _test_eager_guard():
    dense_x = paddle.to_tensor(np.array([-2, 0, 1]).astype('float32'))
    sparse_x = dense_x.to_sparse_coo(1)
    out = paddle.sparse.functional.relu(sparse_x)