oneflow.nn.Mish

class oneflow.nn.Mish(inplace: bool = False)

Applies the element-wise function:

\[\text{Mish}(x) = x * \text{Tanh}(\text{Softplus}(x))\]
Shape:
  • Input: \((N, *)\) where * means, any number of additional dimensions

  • Output: \((N, *)\), same shape as the input

For example:

>>> import numpy as np
>>> import oneflow as flow

>>> x = np.array([1, 2, 3]).astype(np.float32)
>>> input = flow.Tensor(x)
>>> mish = flow.nn.Mish()

>>> out = mish(input)
>>> out
tensor([0.8651, 1.9440, 2.9865], dtype=oneflow.float32)