Mish

class paddle.nn. Mish ( name=None ) [源代码]

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} \]

参数

  • name (str,可选) - 具体用法请参见 Name,一般无需设置,默认值为 None。

形状

  • input:任意形状的 Tensor。

  • output:和 input 具有相同形状的 Tensor。

代码示例

>>> import paddle

>>> x = paddle.to_tensor([-5., 0., 5.])
>>> m = paddle.nn.Mish()
>>> out = m(x)
>>> print(out)
Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
[-0.03357624,  0.        ,  4.99955177])