From e15d6a51d1013302150eaba54f16630fbaa15470 Mon Sep 17 00:00:00 2001 From: Qwerty71 <33108072+Qwerty71@users.noreply.github.com> Date: Tue, 31 Dec 2019 21:45:15 -0500 Subject: [PATCH 1/7] Add usage example for tf.math.polyval --- tensorflow/python/ops/math_ops.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 0ca39af2ed2379..c487430422485c 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -4237,6 +4237,24 @@ def polyval(coeffs, x, name=None): Returns: A `tensor` of the shape as the expression p(x) with usual broadcasting rules for element-wise addition and multiplication applied. + + Usage Example: + + >>> y = tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0) + >>> print(y) + tf.Tensor(21, shape=(), dtype=int32) + + `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) + >>> y = tf.math.polyval([theta1, theta2, theta3], x) + >>> print(y) + tf.Tensor(21, shape=(), dtype=int32) @compatibility(numpy) Equivalent to numpy.polyval. From 2321f85910f63670b681496f6cfeb629e0f1a727 Mon Sep 17 00:00:00 2001 From: Qwerty71 <33108072+Qwerty71@users.noreply.github.com> Date: Tue, 31 Dec 2019 21:53:13 -0500 Subject: [PATCH 2/7] Fix usage example for tf.math.polyval --- tensorflow/python/ops/math_ops.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index c487430422485c..8a91d6734736af 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -4240,21 +4240,21 @@ def polyval(coeffs, x, name=None): Usage Example: - >>> y = tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0) - >>> print(y) - tf.Tensor(21, shape=(), dtype=int32) - - `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) - >>> y = tf.math.polyval([theta1, theta2, theta3], x) - >>> print(y) - tf.Tensor(21, shape=(), dtype=int32) + >>> y = tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0) + >>> print(y) + tf.Tensor(21, shape=(), dtype=int32) + + `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) + >>> y = tf.math.polyval([theta1, theta2, theta3], x) + >>> print(y) + tf.Tensor(21, shape=(), dtype=int32) @compatibility(numpy) Equivalent to numpy.polyval. From 8a29f1d9d7f63d99187d395dd0bafcab71450f79 Mon Sep 17 00:00:00 2001 From: Qwerty71 <33108072+Qwerty71@users.noreply.github.com> Date: Thu, 2 Jan 2020 16:16:17 -0500 Subject: [PATCH 3/7] Fixing "line too long error" --- tensorflow/python/ops/math_ops.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 8a91d6734736af..54b3b37c83b2c2 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -4244,9 +4244,10 @@ def polyval(coeffs, x, name=None): >>> print(y) tf.Tensor(21, shape=(), dtype=int32) - `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. + `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) From 642072fdf5ef5303f2aa8f1d0b80d2e34927dda9 Mon Sep 17 00:00:00 2001 From: Qwerty71 <33108072+Qwerty71@users.noreply.github.com> Date: Sun, 5 Jan 2020 14:36:50 -0500 Subject: [PATCH 4/7] Update math_ops.py --- tensorflow/python/ops/math_ops.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 54b3b37c83b2c2..3b508c90665b87 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -4229,24 +4229,15 @@ def polyval(coeffs, x, name=None): p(x) = coeffs[n-1] + x * (coeffs[n-2] + ... + x * (coeffs[1] + x * coeffs[0])) - Args: - coeffs: A list of `Tensor` representing the coefficients of the polynomial. - x: A `Tensor` representing the variable of the polynomial. - name: A name for the operation (optional). - - Returns: - A `tensor` of the shape as the expression p(x) with usual broadcasting - rules for element-wise addition and multiplication applied. - Usage Example: >>> y = tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0) >>> print(y) tf.Tensor(21, shape=(), dtype=int32) - `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 + `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) @@ -4257,6 +4248,15 @@ def polyval(coeffs, x, name=None): >>> print(y) tf.Tensor(21, shape=(), dtype=int32) + Args: + coeffs: A list of `Tensor` representing the coefficients of the polynomial. + x: A `Tensor` representing the variable of the polynomial. + name: A name for the operation (optional). + + Returns: + A `tensor` of the shape as the expression p(x) with usual broadcasting + rules for element-wise addition and multiplication applied. + @compatibility(numpy) Equivalent to numpy.polyval. @end_compatibility From 2985896d7c561f538285fc02a96876aec32f7b7b Mon Sep 17 00:00:00 2001 From: Qwerty71 <33108072+Qwerty71@users.noreply.github.com> Date: Tue, 7 Jan 2020 21:06:07 -0500 Subject: [PATCH 5/7] Make requested changes --- tensorflow/python/ops/math_ops.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 3b508c90665b87..601385dffa9152 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -4244,8 +4244,7 @@ def polyval(coeffs, x, name=None): >>> theta1 = tf.Variable(2) >>> theta2 = tf.Variable(1) >>> theta3 = tf.Variable(0) - >>> y = tf.math.polyval([theta1, theta2, theta3], x) - >>> print(y) + >>> tf.math.polyval([theta1, theta2, theta3], x) tf.Tensor(21, shape=(), dtype=int32) Args: From 667d516e13c23d6f419c11f1d825fb78cd40af2a Mon Sep 17 00:00:00 2001 From: Qwerty71 <33108072+Qwerty71@users.noreply.github.com> Date: Fri, 10 Jan 2020 11:44:35 -0500 Subject: [PATCH 6/7] Addresses changes --- tensorflow/python/ops/math_ops.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 601385dffa9152..cf1d4c718b7571 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -4231,8 +4231,7 @@ def polyval(coeffs, x, name=None): Usage Example: - >>> y = tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0) - >>> print(y) + >>> tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0) tf.Tensor(21, shape=(), dtype=int32) `tf.math.polyval` can also be used in polynomial regression. Taking From ee6e9b3461cd74513bae7fa0b9c0127637f9d752 Mon Sep 17 00:00:00 2001 From: Qwerty71 <33108072+Qwerty71@users.noreply.github.com> Date: Thu, 16 Jan 2020 00:33:27 -0500 Subject: [PATCH 7/7] Update math_ops.py --- tensorflow/python/ops/math_ops.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index cf1d4c718b7571..72d62c973239f6 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -4232,7 +4232,7 @@ def polyval(coeffs, x, name=None): Usage Example: >>> tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0) - tf.Tensor(21, shape=(), dtype=int32) + `tf.math.polyval` can also be used in polynomial regression. Taking advantage of this function can facilitate writing a polynomial equation @@ -4244,7 +4244,7 @@ def polyval(coeffs, x, name=None): >>> theta2 = tf.Variable(1) >>> theta3 = tf.Variable(0) >>> tf.math.polyval([theta1, theta2, theta3], x) - tf.Tensor(21, shape=(), dtype=int32) + Args: coeffs: A list of `Tensor` representing the coefficients of the polynomial.