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

Function log

imperative/python/megengine/functional/elemwise.py:679–709  ·  view source on GitHub ↗

r"""Element-wise :math:`\operatorname{log}(x)` function. Calculates an approximation to the natural (base :math:`e`) logarithm for each element :math:`x_i` of the input tensor :math:`x`. This function has domain ``[+0, +infinity]`` and codomain ``[-infinity, +infinity]``. Args

(x)

Source from the content-addressed store, hash-verified

677
678
679def log(x):
680 r"""Element-wise :math:`\operatorname{log}(x)` function.
681
682 Calculates an approximation to the natural (base :math:`e`) logarithm for each element :math:`x_i` of the input tensor :math:`x`.
683
684 This function has domain ``[+0, +infinity]`` and codomain ``[-infinity, +infinity]``.
685
686 Args:
687 x: input tensor. Should have a floating-point data type.
688
689 Returns:
690 a tensor containing the evaluated natural logarithm result for each element in :math:`x`.
691 The returned tensor must have a floating-point data type determined by :ref:`dtype-promotion`.
692
693 .. admonition:: Special cases
694
695 For floating-point operands,
696
697 * If :math:`x_i` is ``NaN``, the result is ``NaN``.
698 * If :math:`x_i` is less than ``0``, the result is ``NaN``.
699 * If :math:`x_i` is either ``+0`` or ``-0``, the result is ``-infinity``.
700 * If :math:`x_i` is ``1``, the result is ``+0``.
701 * If :math:`x_i` is ``+infinity``, the result is ``+infinity``.
702
703 Examples:
704
705 >>> F.log([1, F.exp(1)])
706 Tensor([0. 1.], device=xpux:0)
707
708 """
709 return _elwise(x, mode=Elemwise.Mode.LOG)
710
711
712def log1p(x):

Callers 8

fFunction · 0.90
gFunction · 0.90
cross_entropyFunction · 0.70
binary_cross_entropyFunction · 0.70
_safelogFunction · 0.70
logsumexpFunction · 0.70
sampleMethod · 0.50
tqt_grad_ruleFunction · 0.50

Calls 1

_elwiseFunction · 0.50

Tested by 2

fFunction · 0.72
gFunction · 0.72