mish¶
mish 激活层。计算公式如下:
\[ \begin{align}\begin{aligned}\begin{split}softplus(x) = \begin{cases} x, \text{if } x > \text{threshold} \\ \ln(1 + e^{x}), \text{otherwise} \end{cases}\end{split}\\Mish(x) = x * \tanh(softplus(x))\end{aligned}\end{align} \]
返回¶
Tensor
,数据类型和形状同x
一致。
代码示例¶
import paddle
import paddle.nn.functional as F
x = paddle.to_tensor([-5., 0., 5.])
out = F.mish(x) # [-0.03357624, 0., 4.99955208]