MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / logsigmoid

Function logsigmoid

imperative/python/megengine/functional/nn.py:954–971  ·  view source on GitHub ↗

r"""Applies the element-wise function: .. math:: \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, d

(inp: Tensor)

Source from the content-addressed store, hash-verified

952
953
954def logsigmoid(inp: Tensor) -> Tensor:
955 r"""Applies the element-wise function:
956
957 .. math::
958 \text{logsigmoid}(x) = \log(\frac{ 1 }{ 1 + \exp(-x)})
959 = \log(1/(1 + \exp(-x)))
960 = - \log(1 + \exp(-x))
961 = - \text{softplus}(-x)
962
963 Examples:
964 >>> import numpy as np
965 >>> x = Tensor(np.arange(-5, 5, dtype=np.float32))
966 >>> y = F.logsigmoid(x)
967 >>> y.numpy().round(decimals=4)
968 array([-5.0067, -4.0182, -3.0486, -2.1269, -1.3133, -0.6931, -0.3133,
969 -0.1269, -0.0486, -0.0181], dtype=float32)
970 """
971 return _elwise(inp, mode=Elemwise.Mode.LOGSIGMOID)
972
973
974def logsumexp(

Callers 1

binary_cross_entropyFunction · 0.70

Calls 1

_elwiseFunction · 0.50

Tested by

no test coverage detected