megengine.functional.nn.logsigmoid

logsigmoid(inp)[源代码]

对每个元素应用函数:

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

实际案例

>>> 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)
返回类型

Tensor