DHZS / tf-deformable-conv-layer

TensorFlow implementation of Deformable Convolutional Layer
MIT License
82 stars 37 forks source link

It assumes batch_size is constant if you use Keras #3

Closed Golbstein closed 5 years ago

Golbstein commented 5 years ago

line 118 in deformable_conv_layer.py batch_size = int(inputs.get_shape()[0])

But the batch_size dimension in Keras layers are always None and it crushes

example:

from deform_conv.deformable_conv_layer import DeformableConvLayer
from keras.layers import Input
x = Input((28, 28, 1))
output = DeformableConvLayer(filters=6, kernel_size=3, strides=1, 
                             padding='valid', dilation_rate=1, 
                             num_deformable_group=1)(x)

throws the error:

TypeError Traceback (most recent call last)

in 4 output = DeformableConvLayer(filters=6, kernel_size=3, strides=1, 5 padding='valid', dilation_rate=1, ----> 6 num_deformable_group=1)(x) /usr/local/lib/python3.5/dist-packages/keras/engine/base_layer.py in __call__(self, inputs, **kwargs) 455 # Actually call the layer, 456 # collecting output(s), mask(s), and shape(s). --> 457 output = self.call(inputs, **kwargs) 458 output_mask = self.compute_mask(inputs, previous_mask) 459 /workspace/Dropbox/For_AI_Machines/Jenia/deform-conv/deform_conv/deformable_conv_layer.py in call(self, inputs, training, **kwargs) 112 113 # some length --> 114 batch_size = int(inputs.get_shape()[0]) 115 channel_in = int(inputs.get_shape()[-1]) 116 in_h, in_w = [int(i) for i in inputs.get_shape()[1: 3]] # input feature map size TypeError: __int__ returned non-int (type NoneType)
DHZS commented 5 years ago

Sorry, the code can only run in tf eager execution.