import unittest

import tensorflow as tf
import tensorflow_addons as tfa


class TestTensorflowAddons(unittest.TestCase):
    def test_tfa_image(self):
        img_raw = tf.io.read_file('/input/tests/data/dot.png')
        img = tf.io.decode_image(img_raw)
        img = tf.image.convert_image_dtype(img, tf.float32)
        mean = tfa.image.mean_filter2d(img, filter_shape=1)

        self.assertEqual(1, len(mean))
import unittest

import numpy as np
import tensorflow as tf
import tensorflow_addons as tfa


class TestTensorflowAddons(unittest.TestCase):
    def test_tfa_image(self):
        img_raw = tf.io.read_file('/input/tests/data/dot.png')
        img = tf.io.decode_image(img_raw)
        img = tf.image.convert_image_dtype(img, tf.float32)
        mean = tfa.image.mean_filter2d(img, filter_shape=1)

        self.assertEqual(1, len(mean))
    
    # This test exercises TFA Custom Op. See: b/145555176
    def test_gelu(self):
        x = tf.constant([[0.5, 1.2, -0.3]])
        layer = tfa.layers.GELU()
        result = layer(x)

        self.assertEqual((1, 3), result.shape)
Add a test exercising TFA custom op.
Add a test exercising TFA custom op.

To prevent future regression.

BUG=145555176

  import unittest
  
+ import numpy as np
  import tensorflow as tf
  import tensorflow_addons as tfa
  
  
  class TestTensorflowAddons(unittest.TestCase):
      def test_tfa_image(self):
          img_raw = tf.io.read_file('/input/tests/data/dot.png')
          img = tf.io.decode_image(img_raw)
          img = tf.image.convert_image_dtype(img, tf.float32)
          mean = tfa.image.mean_filter2d(img, filter_shape=1)
  
          self.assertEqual(1, len(mean))
+     
+     # This test exercises TFA Custom Op. See: b/145555176
+     def test_gelu(self):
+         x = tf.constant([[0.5, 1.2, -0.3]])
+         layer = tfa.layers.GELU()
+         result = layer(x)
+ 
+         self.assertEqual((1, 3), result.shape)
Add a test exercising TFA custom op.
## Code Before:
import unittest

import tensorflow as tf
import tensorflow_addons as tfa


class TestTensorflowAddons(unittest.TestCase):
    def test_tfa_image(self):
        img_raw = tf.io.read_file('/input/tests/data/dot.png')
        img = tf.io.decode_image(img_raw)
        img = tf.image.convert_image_dtype(img, tf.float32)
        mean = tfa.image.mean_filter2d(img, filter_shape=1)

        self.assertEqual(1, len(mean))
## Instruction:
Add a test exercising TFA custom op.
## Code After:
import unittest

import numpy as np
import tensorflow as tf
import tensorflow_addons as tfa


class TestTensorflowAddons(unittest.TestCase):
    def test_tfa_image(self):
        img_raw = tf.io.read_file('/input/tests/data/dot.png')
        img = tf.io.decode_image(img_raw)
        img = tf.image.convert_image_dtype(img, tf.float32)
        mean = tfa.image.mean_filter2d(img, filter_shape=1)

        self.assertEqual(1, len(mean))
    
    # This test exercises TFA Custom Op. See: b/145555176
    def test_gelu(self):
        x = tf.constant([[0.5, 1.2, -0.3]])
        layer = tfa.layers.GELU()
        result = layer(x)

        self.assertEqual((1, 3), result.shape)