thresholded_relu

paddle.nn.functional. thresholded_relu ( x: Tensor, threshold: float = 1.0, value: float = 0.0, name: str | None = None ) Tensor [source]

thresholded relu activation.

\[\begin{split}thresholded\_relu(x) = \left\{ \begin{array}{rl} x,& \text{if } \ x > threshold \\ value,& \text{otherwise} \end{array} \right.\end{split}\]
Parameters
  • x (Tensor) – The input Tensor with data type float32, float64.

  • threshold (float, optional) – The value of threshold for thresholded_relu. Default is 1.0

  • value (float, optional) – The value to replace with when x is less than threshold. Default is 0.0

  • name (str|None, 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.])
>>> out = F.thresholded_relu(x)
>>> print(out)
Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
[2., 0., 0.])