From ec49fa42781566ae1770dd341def5b083ad097df Mon Sep 17 00:00:00 2001 From: Harsh188 Date: Mon, 24 Aug 2020 15:32:18 +0530 Subject: [PATCH 1/6] initial documentation modifications --- tensorflow/python/ops/math_ops.py | 112 ++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 606cb97f4ec..c01e491e439 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -533,6 +533,30 @@ _mul.__doc__ = ( @tf_export("math.subtract", "subtract") @dispatch.add_dispatch_support def subtract(x, y, name=None): + """Returns x - y element-wise. + + *Note*: Subtract supports broadcasting. More about broadcasting + [here](https://numpy.org/doc/stable/user/basics.broadcasting.html) + + For example: + Both input and output have a range `(-inf, inf)`. + + # `x` and `y` are tensors of shape (1) + >>> x = tf.constant([1.0, -1.0, 5.0, -2.0, 0.0]) + >>> y = tf.constant([5.0, 1.0, 3.7, -19.9, float("inf")]) + >>> tf.subtract(x,y) + + + Args: + x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, + `float32`, `float64`, `uint8`, `int8`, `int16`, `int32`, `int64`, `complex64`, + `complex128`, `string`. + y: A `Tensor`. Must have the same type as x. + name: A name for the operation (optional). + Returns: + A `Tensor`. Has the same type as x. + """ return gen_math_ops.sub(x, y, name) @@ -4927,3 +4951,91 @@ def rsqrt(x, name=None): A `tf.Tensor`. Has the same type as `x`. """ return gen_math_ops.rsqrt(x, name) + + +@tf_export("math.add", v1=["math.add","add"]) +@deprecation.deprecated_endpoints("add") +@dispatch.add_dispatch_support +def add(x,y,name=None): + """Returns x + y element-wise. + + *NOTE*: `Add` supports broadcasting. `AddN` does not. More about broadcasting + [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) + + Given two input tensors, the `tf.add` operation computes the sum for every element in the tensor. + + For example: + Both input and output have a range `(-inf, inf)`. + + # `x` and `y` are tensors of shape (1) + >>> x = tf.constant([1.0, -1.0, 5.0, -2.0, 0.0]) + >>> y = tf.constant([5.0, 1.0, 3.7, -19.9, float("inf")]) + >>> tf.add(x,y) + + + Args: + x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, + `float32`, `float64`, `uint8`, `int8`, `int16`, `int32`, `int64`, `complex64`, + `complex128`, `string`. + y: A `Tensor`. Must have the same type as x. + name: A name for the operation (optional). + Returns: + A `Tensor`. Has the same type as x. + """ + return gen_math_ops.add(x,y,name) + + +@tf_export("math.acos", v1=["math.acos","acos"]) +@deprecation.deprecated_endpoints("acos") +@dispatch.add_dispatch_support +def acos(x,name=None): + """Computes acos of x element-wise. + + Provided an input tensor, the `tf.math.acos` operation returns the inverse cosine of + each element of the tensor. If `y = tf.math.cos(x)` then, `x = tf.math.acos(y)`. + + Input range is `[-1, 1]` and the output has a range of `[0, pi]`. + + For example: + + # `x` is a tensor of the shape(1) + >>> x = tf.constant([1.0, -0.5, 3.4, 0.2, 0.0, -2], dtype = tf.float32) + >>> tf.math.acos(x) + + + Args: + x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, + `float32`, `float64`, `uint8`, `int8`, `int16`, `int32`, `int64`, `complex64`, + `complex128`, `string`. + name: A name for the operation (optional). + Returns: + A `Tensor`. Has the same type as x. + """ + return gen_math_ops.acos(x,name) + + +@tf_export("math.floor", v1=["math.floor","floor"]) +@deprecation.deprecated_endpoints("floor") +@dispatch.add_dispatch_support +def floor(x,name=None): + """Returns element-wise largest integer not greater than x. + + Both input range is `(-inf,inf)` and the ouput range is all integer values. + + For example: + + >>> x = tf.constant([1.3324, -1.5, 5.555, -2.532, 0.99, float("inf")]) + >>> tf.floor(x) + + + Args: + x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`. + name: A name for the operation (optional). + Returns: + A `Tensor`. Has the same type as x. + """ + return gen_math_ops.floor(x,name) \ No newline at end of file From 9575ffeebb83278924c075aff9c3a6cf77d2f756 Mon Sep 17 00:00:00 2001 From: Harsh188 Date: Mon, 24 Aug 2020 15:37:31 +0530 Subject: [PATCH 2/6] minor grammar change --- tensorflow/python/ops/math_ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index c01e491e439..562b9f0a2a5 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -5023,7 +5023,7 @@ def acos(x,name=None): def floor(x,name=None): """Returns element-wise largest integer not greater than x. - Both input range is `(-inf,inf)` and the ouput range is all integer values. + Both input range is `(-inf,inf)` and the ouput range consists of all integer values. For example: From b65191ffd1de80c081023ab17c24b338856917b0 Mon Sep 17 00:00:00 2001 From: Harsh188 Date: Wed, 26 Aug 2020 15:35:54 +0530 Subject: [PATCH 3/6] requested changes --- tensorflow/python/ops/math_ops.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 562b9f0a2a5..6b9b87f689d 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -538,10 +538,10 @@ def subtract(x, y, name=None): *Note*: Subtract supports broadcasting. More about broadcasting [here](https://numpy.org/doc/stable/user/basics.broadcasting.html) - For example: Both input and output have a range `(-inf, inf)`. - # `x` and `y` are tensors of shape (1) + For example: + >>> x = tf.constant([1.0, -1.0, 5.0, -2.0, 0.0]) >>> y = tf.constant([5.0, 1.0, 3.7, -19.9, float("inf")]) >>> tf.subtract(x,y) @@ -4963,11 +4963,11 @@ def add(x,y,name=None): [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) Given two input tensors, the `tf.add` operation computes the sum for every element in the tensor. - - For example: + Both input and output have a range `(-inf, inf)`. - # `x` and `y` are tensors of shape (1) + For example: + >>> x = tf.constant([1.0, -1.0, 5.0, -2.0, 0.0]) >>> y = tf.constant([5.0, 1.0, 3.7, -19.9, float("inf")]) >>> tf.add(x,y) @@ -4999,7 +4999,6 @@ def acos(x,name=None): For example: - # `x` is a tensor of the shape(1) >>> x = tf.constant([1.0, -0.5, 3.4, 0.2, 0.0, -2], dtype = tf.float32) >>> tf.math.acos(x) Date: Sat, 29 Aug 2020 11:36:21 +0530 Subject: [PATCH 4/6] fixed pylint formating issues --- tensorflow/python/ops/math_ops.py | 59 +++++++++++++++++-------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 6b9b87f689d..84a72f1438a 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -535,7 +535,7 @@ _mul.__doc__ = ( def subtract(x, y, name=None): """Returns x - y element-wise. - *Note*: Subtract supports broadcasting. More about broadcasting + *Note*: Subtract supports broadcasting. More about broadcasting [here](https://numpy.org/doc/stable/user/basics.broadcasting.html) Both input and output have a range `(-inf, inf)`. @@ -549,9 +549,9 @@ def subtract(x, y, name=None): array([-4. , -2. , 1.3, 17.9, -inf], dtype=float32)> Args: - x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, - `float32`, `float64`, `uint8`, `int8`, `int16`, `int32`, `int64`, `complex64`, - `complex128`, `string`. + x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, + `float32`, `float64`, `uint8`, `int8`, `int16`, `int32`, `int64`, + `complex64`, `complex128`, `string`. y: A `Tensor`. Must have the same type as x. name: A name for the operation (optional). Returns: @@ -4953,17 +4953,18 @@ def rsqrt(x, name=None): return gen_math_ops.rsqrt(x, name) -@tf_export("math.add", v1=["math.add","add"]) +@tf_export("math.add", v1=["math.add", "add"]) @deprecation.deprecated_endpoints("add") @dispatch.add_dispatch_support -def add(x,y,name=None): +def add(x, y, name=None): """Returns x + y element-wise. *NOTE*: `Add` supports broadcasting. `AddN` does not. More about broadcasting [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) - Given two input tensors, the `tf.add` operation computes the sum for every element in the tensor. - + Given two input tensors, the `tf.add` operation computes the sum + for every element in the tensor. + Both input and output have a range `(-inf, inf)`. For example: @@ -4973,10 +4974,11 @@ def add(x,y,name=None): >>> tf.add(x,y) - + Args: - x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, - `float32`, `float64`, `uint8`, `int8`, `int16`, `int32`, `int64`, `complex64`, + x: A `Tensor`. Must be one of the following types: + `bfloat16`, `half`, `float32`, `float64`, `uint8`, `int8`, + `int16`, `int32`, `int64`, `complex64`, `complex128`, `string`. y: A `Tensor`. Must have the same type as x. name: A name for the operation (optional). @@ -4986,14 +4988,15 @@ def add(x,y,name=None): return gen_math_ops.add(x,y,name) -@tf_export("math.acos", v1=["math.acos","acos"]) +@tf_export("math.acos", v1=["math.acos", "acos"]) @deprecation.deprecated_endpoints("acos") @dispatch.add_dispatch_support -def acos(x,name=None): +def acos(x, name=None): """Computes acos of x element-wise. - Provided an input tensor, the `tf.math.acos` operation returns the inverse cosine of - each element of the tensor. If `y = tf.math.cos(x)` then, `x = tf.math.acos(y)`. + Provided an input tensor, the `tf.math.acos` operation + returns the inverse cosine of each element of the tensor. + If `y = tf.math.cos(x)` then, `x = tf.math.acos(y)`. Input range is `[-1, 1]` and the output has a range of `[0, pi]`. @@ -5006,9 +5009,9 @@ def acos(x,name=None): dtype=float32)> Args: - x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, - `float32`, `float64`, `uint8`, `int8`, `int16`, `int32`, `int64`, `complex64`, - `complex128`, `string`. + x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, + `float32`, `float64`, `uint8`, `int8`, `int16`, `int32`, + `int64`, `complex64`, `complex128`, `string`. name: A name for the operation (optional). Returns: A `Tensor`. Has the same type as x. @@ -5016,25 +5019,27 @@ def acos(x,name=None): return gen_math_ops.acos(x,name) -@tf_export("math.floor", v1=["math.floor","floor"]) +@tf_export("math.floor", v1=["math.floor", "floor"]) @deprecation.deprecated_endpoints("floor") @dispatch.add_dispatch_support -def floor(x,name=None): +def floor(x, name=None): """Returns element-wise largest integer not greater than x. - - Both input range is `(-inf,inf)` and the ouput range consists of all integer values. - + + Both input range is `(-inf, inf)` and the + ouput range consists of all integer values. + For example: - >>> x = tf.constant([1.3324, -1.5, 5.555, -2.532, 0.99, float("inf")]) + >>> x = tf.constant([1.3324, -1.5, 5.555, -2.532, 0.99, float("inf")]) >>> tf.floor(x) - + Args: - x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`. + x: A `Tensor`. Must be one of the following types: + `bfloat16`, `half`, `float32`, `float64`. name: A name for the operation (optional). Returns: A `Tensor`. Has the same type as x. """ - return gen_math_ops.floor(x,name) \ No newline at end of file + return gen_math_ops.floor(x,name) From 875936191c2f7616c43f425d4c03fb52f96370f1 Mon Sep 17 00:00:00 2001 From: Harsh188 Date: Mon, 31 Aug 2020 10:39:51 +0530 Subject: [PATCH 5/6] fixed Build failures pt2 --- tensorflow/python/ops/math_ops.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 84a72f1438a..e7b9ffd3cdd 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -537,7 +537,7 @@ def subtract(x, y, name=None): *Note*: Subtract supports broadcasting. More about broadcasting [here](https://numpy.org/doc/stable/user/basics.broadcasting.html) - + Both input and output have a range `(-inf, inf)`. For example: @@ -4985,7 +4985,7 @@ def add(x, y, name=None): Returns: A `Tensor`. Has the same type as x. """ - return gen_math_ops.add(x,y,name) + return gen_math_ops.add(x, y, name) @tf_export("math.acos", v1=["math.acos", "acos"]) @@ -5016,7 +5016,7 @@ def acos(x, name=None): Returns: A `Tensor`. Has the same type as x. """ - return gen_math_ops.acos(x,name) + return gen_math_ops.acos(x, name) @tf_export("math.floor", v1=["math.floor", "floor"]) @@ -5042,4 +5042,4 @@ def floor(x, name=None): Returns: A `Tensor`. Has the same type as x. """ - return gen_math_ops.floor(x,name) + return gen_math_ops.floor(x, name) From c76508b9e7972602dfe088624ac60477208f1fe4 Mon Sep 17 00:00:00 2001 From: Harsh188 Date: Sat, 19 Sep 2020 22:31:08 +0530 Subject: [PATCH 6/6] changing example output format --- tensorflow/python/ops/math_ops.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index e7b9ffd3cdd..e13e6c8b0e0 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -545,8 +545,8 @@ def subtract(x, y, name=None): >>> x = tf.constant([1.0, -1.0, 5.0, -2.0, 0.0]) >>> y = tf.constant([5.0, 1.0, 3.7, -19.9, float("inf")]) >>> tf.subtract(x,y) - + Args: x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, @@ -4972,8 +4972,8 @@ def add(x, y, name=None): >>> x = tf.constant([1.0, -1.0, 5.0, -2.0, 0.0]) >>> y = tf.constant([5.0, 1.0, 3.7, -19.9, float("inf")]) >>> tf.add(x,y) - + Args: x: A `Tensor`. Must be one of the following types: @@ -5004,9 +5004,9 @@ def acos(x, name=None): >>> x = tf.constant([1.0, -0.5, 3.4, 0.2, 0.0, -2], dtype = tf.float32) >>> tf.math.acos(x) - + Args: x: A `Tensor`. Must be one of the following types: `bfloat16`, `half`, @@ -5032,8 +5032,8 @@ def floor(x, name=None): >>> x = tf.constant([1.3324, -1.5, 5.555, -2.532, 0.99, float("inf")]) >>> tf.floor(x) - + Args: x: A `Tensor`. Must be one of the following types: