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.

thresholded_relu(x)={x,if  x>thresholdvalue,otherwise
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.])