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
from megengine import tensor
import megengine.functional as F

x = tensor(np.arange(-5, 5, dtype=np.float32))
y = F.logsigmoid(x)
print(y.numpy().round(decimals=4))

输出:

[-5.0067 -4.0182 -3.0486 -2.1269 -1.3133 -0.6931 -0.3133 -0.1269 -0.0486
-0.0181]
返回类型

Tensor