megengine.functional.nn.logsigmoid

logsigmoid(inp)[source]

Applies the element-wise function:

\[\text{logsigmoid}(x) = \log(\frac{ 1 }{ 1 + \exp(-x)}) = \log(1/(1 + \exp(-x))) = - \log(1 + \exp(-x)) = - \text{softplus}(-x)\]

Examples

>>> import numpy as np
>>> x = Tensor(np.arange(-5, 5, dtype=np.float32))
>>> y = F.logsigmoid(x)
>>> y.numpy().round(decimals=4)
array([-5.0067, -4.0182, -3.0486, -2.1269, -1.3133, -0.6931, -0.3133,
       -0.1269, -0.0486, -0.0181], dtype=float32)
Return type

Tensor