Repository: tensorflow/addons

Issue:
Replace ops.name_scope by tf.name_scope
Examples:

https://github.com/tensorflow/addons/blob/8dad6d2f9b8a7d8a6c103249e960185d1f573488/tensorflow_addons/image/distort_image_ops.py#L134

https://github.com/tensorflow/addons/blob/8dad6d2f9b8a7d8a6c103249e960185d1f573488/tensorflow_addons/image/transform_ops.py#L74

We should use tf public API `tf.name_scope`.


Discussion:
ops.convert_to_tensor is also need to be replaced by tf.convert_to_tensor 
By the way, it's easy to find all files by running `git grep --name-only 'ops.name_scope'`
The suggestion made above `(tf.name_scope(name))` may need hardening due to an exception when `name=None`:

```
/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 6480, in __init__
    raise ValueError("name for name_scope must be a string.")
ValueError: name for name_scope must be a string.
```

One possible workaround would be to do ` with tf.name_scope(str(name)):` and cast None -> string.  
Good question. We can give it a default value by `with tf.name_scope(name or default_name)` :-)
@facaiy I would like to work on it
Sure, I'll work on it. Any tips on how to start?
@shreyashub You can begin by cloning the code, running in the docker container as explained on the home page, and once the code works as is, then create your branch, search for all the files with the help of grep command suggested by @facaiy, change the code, and then test it again. Let us know if that helps you start.

Welcome, Shreyas :-) 
And you might want to read our guide for contributor as well: https://github.com/tensorflow/addons/blob/master/CONTRIBUTING.md
@armando-fandango @facaiy Thank you for such a kind and warm welcome.
 I'll proceed as advised and let you know if anything comes up.
https://github.com/tensorflow/tensorflow/blob/8886c844249703a0dcd79eba53a40bfbd5c11b9f/tensorflow/python/framework/ops.py#L6444
As far as I can see in the tf.name_scope(), it no longer takes default_name and values as arguments. 
To resolve default name we can use `tf.name_scope(name or default_name)` , but I'm confused as to how we can resolve the values part.
@shreyashub Sorry for the delay, I afraid we don't need `values` attribute any more in tf 2.0. 
cc @karmel  Karmel, please correct me if I'm wrong.
@facaiy that is my understanding as well.

Resolving patch:
diff --git a/tensorflow_addons/image/transform_ops.py b/tensorflow_addons/image/transform_ops.py
--- a/tensorflow_addons/image/transform_ops.py
+++ b/tensorflow_addons/image/transform_ops.py
@@ -71,9 +71,9 @@ def transform(images,
       TypeError: If `image` is an invalid type.
       ValueError: If output shape is not 1-D int32 Tensor.
     """
-    with ops.name_scope(name, "transform"):
-        image_or_images = ops.convert_to_tensor(images, name="images")
-        transform_or_transforms = ops.convert_to_tensor(
+    with tf.name_scope(name or "transform"):
+        image_or_images = tf.convert_to_tensor(images, name="images")
+        transform_or_transforms = tf.convert_to_tensor(
             transforms, name="transforms", dtype=tf.dtypes.float32)
         if image_or_images.dtype.base_dtype not in _IMAGE_DTYPES:
             raise TypeError("Invalid dtype %s." % image_or_images.dtype)
@@ -91,7 +91,7 @@ def transform(images,
         if output_shape is None:
             output_shape = tf.shape(images)[1:3]
 
-        output_shape = ops.convert_to_tensor(
+        output_shape = tf.convert_to_tensor(
             output_shape, tf.dtypes.int32, name="output_shape")
 
         if not output_shape.get_shape().is_compatible_with([2]):
@@ -168,7 +168,7 @@ def flat_transforms_to_matrices(transforms, name=None):
       ValueError: If `transforms` have an invalid shape.
     """
     with tf.name_scope(name or "flat_transforms_to_matrices"):
-        transforms = ops.convert_to_tensor(transforms, name="transforms")
+        transforms = tf.convert_to_tensor(transforms, name="transforms")
         if transforms.shape.ndims not in (1, 2):
             raise ValueError(
                 "Transforms should be 1D or 2D, got: %s" % transforms)
@@ -203,7 +203,7 @@ def matrices_to_flat_transforms(transform_matrices, name=None):
       ValueError: If `transform_matrices` have an invalid shape.
     """
     with tf.name_scope(name or "matrices_to_flat_transforms"):
-        transform_matrices = ops.convert_to_tensor(
+        transform_matrices = tf.convert_to_tensor(
             transform_matrices, name="transform_matrices")
         if transform_matrices.shape.ndims not in (2, 3):
             raise ValueError(
@@ -233,8 +233,8 @@ def angles_to_projective_transforms(angles,
       A tensor of shape (num_images, 8). Projective transforms which can be
       given to `transform` op.
     """
-    with ops.name_scope(name, "angles_to_projective_transforms"):
-        angle_or_angles = ops.convert_to_tensor(
+    with tf.name_scope(name or "angles_to_projective_transforms"):
+        angle_or_angles = tf.convert_to_tensor(
             angles, name="angles", dtype=tf.dtypes.float32)
         if len(angle_or_angles.get_shape()) == 0:
             angles = angle_or_angles[None]
@@ -264,15 +264,15 @@ def angles_to_projective_transforms(angles,
             axis=1)
 
 
-@ops.RegisterGradient("ImageProjectiveTransformV2")
+@tf.RegisterGradient("ImageProjectiveTransformV2")
 def _image_projective_transform_grad(op, grad):
     """Computes the gradient for ImageProjectiveTransform."""
     images = op.inputs[0]
     transforms = op.inputs[1]
     interpolation = op.get_attr("interpolation")
 
-    image_or_images = ops.convert_to_tensor(images, name="images")
-    transform_or_transforms = ops.convert_to_tensor(
+    image_or_images = tf.convert_to_tensor(images, name="images")
+    transform_or_transforms = tf.convert_to_tensor(
         transforms, name="transforms", dtype=tf.dtypes.float32)
 
     if image_or_images.dtype.base_dtype not in _IMAGE_DTYPES:


Test patch: