swish¶
- paddle.nn.functional. swish ( x, name=None ) [source]
-
swish activation.
\[swish(x) = \frac{x}{1 + e^{-x}}\]- 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.]) >>> out = F.swish(x) >>> print(out) Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True, [-0.23840584, 0. , 0.73105860])