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

Function exp

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

r"""Element-wise :math:`e^x` function. Calculates an approximation to the exponential function for each element :math:`x_i` of the input tensor :math:`x` (:math:`e` raised to the power of :math:`x_i`, where :math:`e` is the base of the natural logarithm). This function has domain

(x)

Source from the content-addressed store, hash-verified

590
591
592def exp(x):
593 r"""Element-wise :math:`e^x` function.
594
595 Calculates an approximation to the exponential function for each element :math:`x_i` of the input tensor :math:`x`
596 (:math:`e` raised to the power of :math:`x_i`, where :math:`e` is the base of the natural logarithm).
597
598 This function has domain ``[-infinity, +infinity]`` and codomain ``[+0, +infinity]``.
599
600 Args:
601 x: input tensor. Should have a floating-point data type.
602
603 Returns:
604 a tensor containing the evaluated exponential function result for each element in :math:`x`.
605 The returned tensor must have a floating-point data type determined by :ref:`dtype-promotion`.
606
607 .. admonition:: Special cases
608
609 For floating-point operands,
610
611 * If :math:`x_i` is ``NaN``, the result is ``NaN``.
612 * If :math:`x_i` is ``+0``, the result is ``1``.
613 * If :math:`x_i` is ``-0``, the result is ``1``.
614 * If :math:`x_i` is ``+infinity``, the result is ``+infinity``.
615 * If :math:`x_i` is ``-infinity``, the result is ``+0``.
616
617 Examples:
618
619 >>> F.exp([0, F.log(2)])
620 Tensor([1. 2.], device=xpux:0)
621
622 """
623 return _elwise(x, mode=Elemwise.Mode.EXP)
624
625
626def expm1(x):

Callers 12

fFunction · 0.90
gFunction · 0.90
logsumexpFunction · 0.70
softmaxFunction · 0.70
softmaxFunction · 0.50
log_add_expFunction · 0.50
gelu_gradFunction · 0.50
sigmoidFunction · 0.50
logsigmoidFunction · 0.50
softplusFunction · 0.50
softplus_gradFunction · 0.50
siluFunction · 0.50

Calls 1

_elwiseFunction · 0.50

Tested by 2

fFunction · 0.72
gFunction · 0.72