Repository: tensorlayer/TensorLayer

Issue:
Error caused by using tl.layers.DeformableConv2d function
### New Issue Checklist

- [x] I have read the [Contribution Guidelines](https://github.com/tensorlayer/tensorlayer/blob/master/CONTRIBUTING.md)
- [ ] I searched for [existing GitHub issues](https://github.com/tensorlayer/tensorlayer/issues)

### Issue Description

An Error caused when using tl.layers.DeformableConv2d.
### Reproducible Code

- Which OS are you using ?
 Windows 7 x64
- Please provide a reproducible code of your issue. Without any reproducible code, you will probably not receive any help.


```python



net = tl.layers.InputLayer(x, name='input_layer')
offset1 = tl.layers.Conv2d(net, 18, (3, 3), (1, 1), act=act, padding='SAME', name='offset1')
net = tl.layers.DeformableConv2d(net, offset1, 32, (3, 3), act=act, name='deformable1')
offset2 = tl.layers.Conv2d(net, 18, (3, 3), (1, 1), act=act, padding='SAME', name='offset2')
net = tl.layers.DeformableConv2d(net, offset2, 64, (3, 3), act=act, name='deformable2')

```
When I used this code provided by [Tensorlayer API documents](http://tensorlayercn.readthedocs.io/zh/latest/modules/layers.html?highlight=deformable#tensorlayer.layers.DeformableConv2d), a TypeError was caused. I found a mistake in [`convolution.py`](https://github.com/tensorlayer/tensorlayer/blob/5dda66397f66f11dff3640ae91a032e5dd5207de/tensorlayer/layers/convolution.py). And I suggest you delete Line 971 in `convolution.py` or do something to fix this error. 





Discussion:
As @Liang-yc said, it works well after removing [Line 971](https://github.com/tensorlayer/tensorlayer/blob/master/tensorlayer/layers/convolution.py#L971)

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -55,8 +55,8 @@ def req_file(filename):
 install_requires = req_file("requirements.txt")
 
 extras_require = {
-    'tf_cpu': ['tensorflow>=1.8.0,<1.9'],
-    'tf_gpu': ['tensorflow-gpu>=1.8.0,<1.9'],
+    'tf_cpu': req_file("requirements_tf_cpu.txt"),
+    'tf_gpu': req_file("requirements_tf_gpu.txt"),
 	'db': req_file("requirements_db.txt"),
 	'dev': req_file("requirements_dev.txt"),
 	'doc': req_file("docs/requirements.txt"),
diff --git a/tensorlayer/layers/convolution.py b/tensorlayer/layers/convolution.py
--- a/tensorlayer/layers/convolution.py
+++ b/tensorlayer/layers/convolution.py
@@ -968,7 +968,7 @@ def _tf_batch_map_offsets(inputs, offsets, grid_offset):
                     name='b_deformableconv2d', shape=(shape[-1]), initializer=b_init, dtype=LayersConfig.tf_dtype,
                     **b_init_args
                 )
-                tf.reshape()
+
                 self.outputs = tf.reshape(
                     tensor=act(tf.nn.conv3d(input_deform, W, strides=[1, 1, 1, 1, 1], padding='VALID', name=None) + b),
                     shape=(tf.shape(self.inputs)[0], input_h, input_w, shape[-1])


Test patch:
diff --git a/tests/test_layers_convolution.py b/tests/test_layers_convolution.py
--- a/tests/test_layers_convolution.py
+++ b/tests/test_layers_convolution.py
@@ -183,6 +183,31 @@ def test_layers_n10(self):
         self.assertEqual(len(self.n10_all_layers), 1)
 
 
+class Layer_DeformableConvolution_Test(unittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+
+        x = tf.placeholder(tf.float32, [None, 299, 299, 3])
+        net = tl.layers.InputLayer(x, name='input_layer')
+
+        offset1 = tl.layers.Conv2d(net, 18, (3, 3), (1, 1), act=tf.nn.relu, padding='SAME', name='offset1')
+        cls.net1 = tl.layers.DeformableConv2d(net, offset1, 32, (3, 3), act=tf.nn.relu, name='deformable1')
+
+        offset2 = tl.layers.Conv2d(cls.net1, 18, (3, 3), (1, 1), act=tf.nn.relu, padding='SAME', name='offset2')
+        cls.net2 = tl.layers.DeformableConv2d(cls.net1, offset2, 64, (3, 3), act=tf.nn.relu, name='deformable2')
+
+    @classmethod
+    def tearDownClass(cls):
+        tf.reset_default_graph()
+
+    def test_net1_shape(self):
+        self.assertEqual(self.net1.outputs.shape[1:], [299, 299, 32])
+
+    def test_net2_shape(self):
+        self.assertEqual(self.net2.outputs.shape[1:], [299, 299, 64])
+
+
 if __name__ == '__main__':
     # tf.logging.set_verbosity(tf.logging.INFO)
     tf.logging.set_verbosity(tf.logging.DEBUG)