relu

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

relu activation. The calculation formula is follows:

\[out = max(x, 0)\]

x is input Tensor.

Parameters
  • x (Tensor) – The input Tensor with data type float32, float64.

  • name (str, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.

Returns

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

Examples

>>> import paddle
>>> import paddle.nn.functional as F

>>> x = paddle.to_tensor([-2, 0, 1], dtype='float32')
>>> out = F.relu(x)
>>> print(out)
Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
[0., 0., 1.])