-
Notifications
You must be signed in to change notification settings - Fork 53
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
I am stuck by this problem in customlayers.py, please help #2
Comments
@Rickgewu, |
keras: 2.0.4 |
My bad @Rickgewu . This project was written using Keras 1.2. Try downgrading to version 1.2 via the command After this, modify the
Somehow forgot to mention the keras version in the README. Let me know if this solves your problem. |
I have downgraded keras to 1.2, but still got the below error: 40 alexnet = get_alexnet(input_size,nb_classes,mean_flag) E:\TEMP\R\KERAS\AlexNet-Experiments-Keras-master\AlexNet-Experiments-Keras-master\Code\alexnet_base.pyc in get_alexnet(input_shape, nb_classes, mean_flag) d:\ProgramData\Anaconda2\lib\site-packages\keras\engine\topology.pyc in call(self, x, mask) d:\ProgramData\Anaconda2\lib\site-packages\keras\layers\core.pyc in build(self, input_shape) d:\ProgramData\Anaconda2\lib\site-packages\keras\engine\topology.pyc in add_weight(self, shape, initializer, name, trainable, regularizer, constraint) d:\ProgramData\Anaconda2\lib\site-packages\keras\initializations.pyc in he_normal(shape, name, dim_ordering) d:\ProgramData\Anaconda2\lib\site-packages\keras\backend\theano_backend.pyc in random_normal_variable(shape, mean, scale, dtype, name) ValueError: scale < 0 |
@Rickgewu . I think the previous problem is solved. To resolve this issue, please try as follows.
|
It works after appending this entry to the json "image_dim_ordering": "th", |
Glad your issue is resolved. |
I've encountered the same problem. |
@DNXie The current code would need some revision to make it work with Keras 2 since some keras API's have changed. If you need to do fast prototyping, I'd suggest installing keras 1.2 on a fresh virtual environment. |
is it possible to run it into miniconda environment. |
TypeError Traceback (most recent call last) ~/Desktop/alx/Code/alexnet_base.py in get_alexnet(input_shape, nb_classes, mean_flag) ~/miniconda3/envs/intel_python/lib/python3.5/site-packages/keras/engine/topology.py in call(self, inputs, **kwargs) ~/miniconda3/envs/intel_python/lib/python3.5/site-packages/keras/layers/core.py in call(self, inputs, mask) ~/Desktop/alx/convnets-keras/convnetskeras/customlayers.py in f(X) ~/miniconda3/envs/intel_python/lib/python3.5/site-packages/keras/backend/theano_backend.py in spatial_2d_padding(x, padding, data_format) TypeError: object of type 'int' has no len() i have done all these thing which have already mentioned in the above comments... |
40 alexnet = get_alexnet(input_size,nb_classes,mean_flag)
41
42 print (alexnet.summary())
E:\TEMP\R\KERAS\AlexNet-Experiments-Keras-master\AlexNet-Experiments-Keras-master\Code\alexnet_base.py in get_alexnet(input_shape, nb_classes, mean_flag)
36
37 conv_2 = MaxPooling2D((3, 3), strides=(2,2))(conv_1)
---> 38 conv_2 = crosschannelnormalization(name="convpool_1")(conv_2)
39 conv_2 = ZeroPadding2D((2,2))(conv_2)
40 conv_2 = merge([
d:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py in call(self, inputs, **kwargs)
583
584 # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 585 output = self.call(inputs, **kwargs)
586 output_mask = self.compute_mask(inputs, previous_mask)
587
d:\ProgramData\Anaconda3\lib\site-packages\keras\layers\core.py in call(self, inputs, mask)
657 if 'mask' in arg_spec.args:
658 arguments['mask'] = mask
--> 659 return self.function(inputs, **arguments)
660
661 def compute_mask(self, inputs, mask=None):
E:\TEMP\R\KERAS\AlexNet-Experiments-Keras-master\AlexNet-Experiments-Keras-master\convnets-keras\convnetskeras\customlayers.py in f(X)
16 square = K.square(X)
17 extra_channels = K.spatial_2d_padding(K.permute_dimensions(square,(0,2,3,1))
---> 18 , (0,half))
19 extra_channels = K.permute_dimensions(extra_channels, (0,3,1,2))
20 scale = k
d:\ProgramData\Anaconda3\lib\site-packages\keras\backend\theano_backend.py in spatial_2d_padding(x, padding, data_format)
995 """
996 assert len(padding) == 2
--> 997 assert len(padding[0]) == 2
998 assert len(padding[1]) == 2
999 top_pad, bottom_pad = padding[0]
TypeError: object of type 'int' has no len()
The text was updated successfully, but these errors were encountered: