Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error of padding #12

Closed
chutongz opened this issue Mar 29, 2018 · 3 comments
Closed

Error of padding #12

chutongz opened this issue Mar 29, 2018 · 3 comments

Comments

@chutongz
Copy link

chutongz commented Mar 29, 2018

Thanks for providing such a great code!
When I run alexnet = get_alexnet(input_size,nb_classes,mean_flag)
It occurs

TypeError                                 Traceback (most recent call last)
<ipython-input-4-aeb62c90d3b4> in <module>()
      1 print(input_size)
----> 2 alexnet = get_alexnet(input_size,nb_classes,mean_flag)
      3 
      4 #print alexnet.summary()

/media/chutz/000FC3F700054C75/AlexNet/AlexNet-Experiments-Keras/Code/alexnet_base.py in get_alexnet(input_shape, nb_classes, mean_flag)
     21 
     22         conv_2 = MaxPooling2D((3, 3), strides=(2,2))(conv_1)
---> 23         conv_2 = crosschannelnormalization(name="convpool_1")(conv_2)
     24         conv_2 = ZeroPadding2D((2,2))(conv_2)
     25 	conv_2 = merge([

~/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py in __call__(self, inputs, **kwargs)
    617 
    618             # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 619             output = self.call(inputs, **kwargs)
    620             output_mask = self.compute_mask(inputs, previous_mask)
    621 

~/anaconda3/lib/python3.6/site-packages/keras/layers/core.py in call(self, inputs, mask)
    661         if has_arg(self.function, 'mask'):
    662             arguments['mask'] = mask
--> 663         return self.function(inputs, **arguments)
    664 
    665     def compute_mask(self, inputs, mask=None):

/media/chutz/000FC3F700054C75/AlexNet/AlexNet-Experiments-Keras/convnets-keras/convnetskeras/customlayers.py in f(X)
     15         half = n // 2
     16         square = K.square(X)
---> 17         extra_channels = K.spatial_2d_padding(K.permute_dimensions(square, (0,2,3,1)) , (0,half))
     18         extra_channels = K.permute_dimensions(extra_channels, (0,3,1,2))
     19         scale = k

~/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in spatial_2d_padding(x, padding, data_format)
   2182     """
   2183     assert len(padding) == 2
-> 2184     assert len(padding[0]) == 2
   2185     assert len(padding[1]) == 2
   2186     if data_format is None:

TypeError: object of type 'int' has no len()

and I used debug on jupyter notebook, it shows

ipdb> padding (0, 2)

Any help is appreciated!!

@duggalrahul
Copy link
Owner

duggalrahul commented Mar 29, 2018

Hi @chutongz,
From the error trace, I can see you are running python 3.6. This project works with the following source versions:-

  • python: 2.7

  • keras: 1.2

  • theano: 0.9.0

@chutongz
Copy link
Author

Hmmmm I changed the kernel into python2.7 but still got the same error

/home/chutz/anaconda3/envs/py2/lib/python2.7/site-packages/keras/backend/tensorflow_backend.pyc in spatial_2d_padding(x, padding, data_format)
   2182     """
   2183     assert len(padding) == 2
-> 2184     assert len(padding[0]) == 2
   2185     assert len(padding[1]) == 2
   2186     if data_format is None:

TypeError: object of type 'int' has no len()

@chutongz
Copy link
Author

chutongz commented Apr 2, 2018

I refered to #2
Changed kears version into 1.2 and added .json file and it works!
Thanks a lot!!

@chutongz chutongz closed this as completed Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants