Evaluate the exponential and constant-power functions at x, and compute each input-gradient contribution for the supplied upstream_gradient.
yexp=ex gexp=uex ypower=xn gpower=unxn−1Here x is the scalar input, n is exponent, u is the upstream gradient, y denotes a function's output, and g denotes its input-gradient contribution. For a zero exponent, define the power output as 1.0 and its gradient as 0.0, including when x is zero.
Return a tuple of four 64-bit floating-point numbers in this order: exponential output, exponential gradient, power output, power gradient.
Input: x = 2, exponent = 0, upstream_gradient = 3
Output: (7.389056, 22.167168, 1.0, 0.0)
Explanation: The zero power is constant, so its gradient contribution is zero.
Input: x = 2, exponent = -2, upstream_gradient = -0.5
Output: (7.389056, -3.694528, 0.25, 0.125)
Input: x = -2, exponent = 3, upstream_gradient = 2
Output: (0.135335, 0.270671, -8.0, 24.0)
np.exp evaluates the exponential for a scalar.
np.power supports fractional exponents for positive bases.
Handle exponent zero before evaluating a negative power of the base.
Accepts: number
Accepts: number
Accepts: number
Evaluate the exponential and constant-power functions at x, and compute each input-gradient contribution for the supplied upstream_gradient.
yexp=ex gexp=uex ypower=xn gpower=unxn−1Here x is the scalar input, n is exponent, u is the upstream gradient, y denotes a function's output, and g denotes its input-gradient contribution. For a zero exponent, define the power output as 1.0 and its gradient as 0.0, including when x is zero.
Return a tuple of four 64-bit floating-point numbers in this order: exponential output, exponential gradient, power output, power gradient.
Input: x = 2, exponent = 0, upstream_gradient = 3
Output: (7.389056, 22.167168, 1.0, 0.0)
Explanation: The zero power is constant, so its gradient contribution is zero.
Input: x = 2, exponent = -2, upstream_gradient = -0.5
Output: (7.389056, -3.694528, 0.25, 0.125)
Input: x = -2, exponent = 3, upstream_gradient = 2
Output: (0.135335, 0.270671, -8.0, 24.0)
np.exp evaluates the exponential for a scalar.
np.power supports fractional exponents for positive bases.
Handle exponent zero before evaluating a negative power of the base.
Accepts: number
Accepts: number
Accepts: number