oneflow.nn.Softsign

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

The SoftSign activation.

The formula is:

\[SoftSign(x) = \frac{x}{1 + |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)
>>> softsign = flow.nn.Softsign()
>>> out = softsign(input)
>>> out
tensor([0.5000, 0.6667, 0.7500], dtype=oneflow.float32)