hardsigmoid¶
- paddle.nn.functional. hardsigmoid ( x, slope=0.1666667, offset=0.5, name=None ) [source]
-
hardsigmoid activation. Calculate the hardsigmoid of input x. A 3-part piecewise linear approximation of sigmoid(https://arxiv.org/abs/1603.00391), which is much faster than sigmoid.
hardsigmoid(x)={0,if x≤−31,if x≥3slope∗x+offset,otherwise- Parameters
-
x (Tensor) – The input Tensor with data type float32, float64.
slope (float, optional) – The slope of hardsigmoid function. Default is 0.1666667.
offset (float, optional) – The offset of hardsigmoid function. Default is 0.5.
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([-4., 5., 1.]) out = F.hardsigmoid(x) # [0., 1., 0.666667]