mindspore.ops.Mish

class mindspore.ops.Mish[source]

Computes MISH(A Self Regularized Non-Monotonic Neural Activation Function) of input tensors element-wise.

The function is shown as follows:

\[\text{output} = x * \tanh(\log(1 + \exp(\text{x})))\]

See more details in A Self Regularized Non-Monotonic Neural Activation Function.

Inputs:
  • x (Tensor) - Tensor of shape \((N, *)\), where \(*\) means, any number of additional dimensions, with float16 or float32 data type.

Outputs:

Tensor, with the same type and shape as the x.

Supported Platforms:

Ascend GPU CPU

Raises

TypeError – If dtype of x is neither float16 nor float32.

Examples

>>> x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
>>> mish = ops.Mish()
>>> output = mish(x)
>>> print(output)
[[-0.3034014  3.9974129 -0.00026832]
 [ 1.9439590  -0.0033576 9.0000000]]