diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 0ca39af2ed2379..72d62c973239f6 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -4229,6 +4229,23 @@ def polyval(coeffs, x, name=None): p(x) = coeffs[n-1] + x * (coeffs[n-2] + ... + x * (coeffs[1] + x * coeffs[0])) + Usage Example: + + >>> tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0) + + + `tf.math.polyval` can also be used in polynomial regression. Taking + advantage of this function can facilitate writing a polynomial equation + as compared to explicitly writing it out, especially for higher degree + polynomials. + + >>> x = tf.constant(3) + >>> theta1 = tf.Variable(2) + >>> theta2 = tf.Variable(1) + >>> theta3 = tf.Variable(0) + >>> tf.math.polyval([theta1, theta2, theta3], x) + + Args: coeffs: A list of `Tensor` representing the coefficients of the polynomial. x: A `Tensor` representing the variable of the polynomial.