Expm1¶
This example implements and tests the expm1 operator - ie. element-wise exp(x) - 1, which is equivalent to that defined for numpy.
-
expm1
(x)¶ Define the expm1 operator by defining the its operator function to be
\[out_{i} = exp(x_{i}) - 1.0\]Parameters: x – The input tensor Returns: Element-wise exp(x) - 1 Examples: >>> import numpy as np >>> from opveclib import evaluate >>> from opveclib.examples import expm1 >>> a = np.array([1e-10, -1e-10]) >>> evaluate(expm1(a)) array([ 1.00000000e-10, -1.00000000e-10]) >>> np.expm1(a) array([ 1.00000000e-10, -1.00000000e-10]) >>> ones = np.ones_like(a) >>> np.exp(a) - ones array([ 1.00000008e-10, -1.00000008e-10])
-
expm1_grad
(x, grad)¶ Define the expm1 gradient operator by defining the its operator function to be
\[out_{i} = exp(x_{i}) * grad_{i}\]Parameters: - x – The input tensor argument
- grad – The input gradient tensor to the gradient operator
Returns: Element-wise gradient of the original operator