Repository: tensorflow/addons

Issue:
Package 0.5.1 against TF2-RC1
Looks like RC1 was released. We were already planning the next minor release so should probably build against this version.

https://groups.google.com/a/tensorflow.org/forum/#!topic/discuss/9kOKxqVsv8Q

cc @facaiy 


Discussion:
Thanks for reminding me, Sean. Totally agree.

I suggest that we should make correlation_cost private, see https://github.com/tensorflow/addons/issues/509 . I'm happy to release 0.5.1 after finishing it. What do you think? 
+@tensorflow/model-maintainers for visibility 

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -69,9 +69,9 @@
 if project_name == TFA_RELEASE:
     # TODO: remove if-else condition when tf supports package consolidation.
     if platform.system() == 'Linux':
-        REQUIRED_PACKAGES.append('tensorflow-gpu == 2.0.0-rc0')
+        REQUIRED_PACKAGES.append('tensorflow-gpu == 2.0.0-rc1')
     else:
-        REQUIRED_PACKAGES.append('tensorflow == 2.0.0-rc0')
+        REQUIRED_PACKAGES.append('tensorflow == 2.0.0-rc1')
 elif project_name == TFA_NIGHTLY:
     # TODO: remove if-else condition when tf-nightly supports package consolidation.
     if platform.system() == 'Linux':
diff --git a/tensorflow_addons/layers/optical_flow.py b/tensorflow_addons/layers/optical_flow.py
--- a/tensorflow_addons/layers/optical_flow.py
+++ b/tensorflow_addons/layers/optical_flow.py
@@ -27,15 +27,15 @@
 
 
 @tf.function
-def correlation_cost(input_a,
-                     input_b,
-                     kernel_size,
-                     max_displacement,
-                     stride_1,
-                     stride_2,
-                     pad,
-                     data_format='channels_last',
-                     name=None):
+def _correlation_cost(input_a,
+                      input_b,
+                      kernel_size,
+                      max_displacement,
+                      stride_1,
+                      stride_2,
+                      pad,
+                      data_format='channels_last',
+                      name=None):
     """Correlation Cost Volume computation.
 
     "FlowNet: Learning Optical Flow with Convolutional Networks"
@@ -141,6 +141,27 @@ def _correlation_cost_grad(op, grad_output):
 
 @keras_utils.register_keras_custom_object
 class CorrelationCost(tf.keras.layers.Layer):
+    """Correlation Cost Layer.
+
+    This layer implements the correlation operation from FlowNet Learning
+    Optical Flow with Convolutional Networks (Fischer et al.):
+    https://arxiv.org/abs/1504.06
+
+    Args:
+        kernel_size: An integer specifying the height and width of the
+            patch used to compute the per-patch costs.
+        max_displacement: An integer specifying the maximum search radius
+            for each position.
+        stride_1: An integer specifying the stride length in the input.
+        stride_2: An integer specifying the stride length in the patch.
+        pad: An integer specifying the paddings in height and width.
+        data_format: Specifies the data format.
+            Possible values are:
+                "channels_last" float [batch, height, width, channels]
+                "channels_first" float [batch, channels, height, width]
+                Defaults to `"channels_last"`.
+    """
+
     def __init__(self, kernel_size, max_displacement, stride_1, stride_2, pad,
                  data_format, **kwargs):
         self.kernel_size = kernel_size
@@ -169,7 +190,7 @@ def call(self, inputs):
         input_a = tf.convert_to_tensor(inputs[0])
         input_b = tf.convert_to_tensor(inputs[1])
 
-        return correlation_cost(
+        return _correlation_cost(
             input_a,
             input_b,
             kernel_size=self.kernel_size,
diff --git a/tensorflow_addons/seq2seq/beam_search_decoder.py b/tensorflow_addons/seq2seq/beam_search_decoder.py
--- a/tensorflow_addons/seq2seq/beam_search_decoder.py
+++ b/tensorflow_addons/seq2seq/beam_search_decoder.py
@@ -764,7 +764,7 @@ def output_dtype(self):
             parent_ids=tf.int32)
 
     def call(self,
-             embeddning,
+             embedding,
              start_tokens,
              end_token,
              initial_state,
@@ -782,7 +782,7 @@ def call(self,
             parallel_iterations=self.parallel_iterations,
             swap_memory=self.swap_memory,
             training=training,
-            decoder_init_input=embeddning,
+            decoder_init_input=embedding,
             decoder_init_kwargs=init_kwargs)
 
 


Test patch:
diff --git a/tensorflow_addons/layers/optical_flow_test.py b/tensorflow_addons/layers/optical_flow_test.py
--- a/tensorflow_addons/layers/optical_flow_test.py
+++ b/tensorflow_addons/layers/optical_flow_test.py
@@ -19,7 +19,7 @@
 
 import numpy as np
 import tensorflow as tf
-from tensorflow_addons.layers.optical_flow import correlation_cost, CorrelationCost
+from tensorflow_addons.layers.optical_flow import CorrelationCost
 from tensorflow_addons.utils import test_utils
 
 
@@ -31,15 +31,13 @@ def _forward(self, input_a, input_b, kernel_size, max_displacement,
         input_a_op = tf.convert_to_tensor(input_a, dtype=tf.float32)
         input_b_op = tf.convert_to_tensor(input_b, dtype=tf.float32)
 
-        output = correlation_cost(
-            input_a_op,
-            input_b_op,
+        output = CorrelationCost(
             kernel_size=kernel_size,
             max_displacement=max_displacement,
             stride_1=stride_1,
             stride_2=stride_2,
             pad=pad,
-            data_format=data_format)
+            data_format=data_format)([input_a_op, input_b_op])
 
         return output
 
@@ -117,15 +115,13 @@ def _gradients(self, data_format):
             input_b_op = tf.convert_to_tensor(input_b)
 
             def correlation_fn(input_a, input_b):
-                return correlation_cost(
-                    input_a,
-                    input_b,
+                return CorrelationCost(
                     kernel_size=kernel_size,
                     max_displacement=max_displacement,
                     stride_1=stride_1,
                     stride_2=stride_2,
                     pad=pad,
-                    data_format=data_format)
+                    data_format=data_format)([input_a, input_b])
 
             theoretical, numerical = tf.test.compute_gradient(
                 correlation_fn, [input_a_op, input_b_op])
@@ -159,7 +155,7 @@ def _keras(self, data_format):
 
             x = [input_a, input_b]
             y = layer(x)
-            model = tf.python.keras.models.Model(x, y)
+            model = tf.keras.models.Model(x, y)
             actual_output = model.predict([val_a, val_b])
 
             expected_output_type = 'float32'