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

errors while call the keras.applications.inception_v3 #87

Open
heroxrq opened this issue Sep 30, 2017 · 2 comments
Open

errors while call the keras.applications.inception_v3 #87

heroxrq opened this issue Sep 30, 2017 · 2 comments

Comments

@heroxrq
Copy link

heroxrq commented Sep 30, 2017

I turn my keras backend from tensorflow to mxnet to use mxnet's multi gpu training. However the code I run successfully in keras tensorflow backend seems not compatible with keras mxnet backend. It prints the following:

Using MXNet backend.
train and valid generator is ok
steps_per_epoch: 55673
validation_steps: 1236
Traceback (most recent call last):
File "train_inception_v3_transfer_learning.py", line 64, in
base_model = InceptionV3(include_top=False, weights=None, input_shape=(3, INPUT_HEIGHT, INPUT_WIDTH))
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/keras/applications/inception_v3.py", line 151, in InceptionV3
(3, 3), strides=(1, 1), border_mode='same')(x)
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 572, in call
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 635, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 166, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/keras/layers/pooling.py", line 160, in call
dim_ordering=self.dim_ordering)
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/keras/layers/pooling.py", line 251, in _pooling_function
border_mode, dim_ordering, pool_mode='avg')
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/keras/backend/mxnet_backend.py", line 33, in func_wrapper
train_ret = func(*args, **kwargs)
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/keras/backend/mxnet_backend.py", line 2912, in pool2d
stride=strides)
File "", line 39, in Pooling
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/mxnet/_ctypes/symbol.py", line 127, in _symbol_creator
ctypes.byref(sym_handle)))
File "/home/xierenqiang/install/anaconda3/lib/python3.6/site-packages/mxnet/base.py", line 129, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: Invalid Input: 'same', valid values are: {'full', 'valid'}, in operator Pooling(name="", stride="(1, 1)", pooling_convention="same", pool_type="avg", kernel="(3, 3)")

@DSLituiev
Copy link

I am getting an error even without specifying input shape with this two simple lines:

from keras.applications.inception_v3 import InceptionV3
#Using MXNet backend.
base_model = InceptionV3(weights='imagenet',
                               include_top=False,
                                #pooling=None,
                               )

error:

[21:10:59] /home/travis/build/dmlc/mxnet-distro/mxnet-build/dmlc-core/include/dmlc/logging.h:308: [21:10:59] src/operator/./pooling-inl.h:214: Check failed: param_.kernel[0] <= dshape[2] + 2 * param_.pad[0] kernel size (3) exceeds input (0 padded to 0)

Stack trace returned 10 entries:
[bt] (0) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0xec23c) [0x7fec5a44123c]
[bt] (1) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x1170ca2) [0x7fec5b4c5ca2]
[bt] (2) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0xf90817) [0x7fec5b2e5817]
[bt] (3) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x16e9531) [0x7fec5ba3e531]
[bt] (4) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x16ead42) [0x7fec5ba3fd42]
[bt] (5) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x16eb686) [0x7fec5ba40686]
[bt] (6) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x16d4e88) [0x7fec5ba29e88]
[bt] (7) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0xe049fe) [0x7fec5b1599fe]
[bt] (8) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0xe0732e) [0x7fec5b15c32e]
[bt] (9) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(MXSymbolInferShape+0x156f) [0x7fec5b154d2f]

------------------------------------------------------------------------
MXNetError                             Traceback (most recent call last)
<ipython-input-2-8dfe2d4abb60> in <module>()
      1 base_model = InceptionV3(weights='imagenet',
----> 2                             include_top=False,
      3                             #pooling=None,
      4                             )
      5

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/keras/applications/inception_v3.py in InceptionV3(include_top, weights, input_tensor, input_shape, classes)
    133     x = MaxPooling2D((3, 3), strides=(2, 2))(x)
    134
--> 135     x = conv2d_bn(x, 80, 1, 1, border_mode='valid')
    136     x = conv2d_bn(x, 192, 3, 3, border_mode='valid')
    137     x = MaxPooling2D((3, 3), strides=(2, 2))(x)

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/keras/applications/inception_v3.py in conv2d_bn(x, nb_filter, nb_row, nb_col, border_mode, subsample, name)
     56                       activation='relu',
     57                       border_mode=border_mode,
---> 58                       name=conv_name)(x)
     59     x = BatchNormalization(axis=bn_axis, name=bn_name)(x)
     60     return x

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/keras/engine/topology.py in __call__(self, x, mask)
    527             # Raise exceptions in case the input is not compatible
    528             # with the input_spec specified in the layer constructor.
--> 529             self.assert_input_compatibility(x)
    530
    531             # Collect input shapes to build layer.

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/keras/engine/topology.py in assert_input_compatibility(self, input)
    462                                          str(K.ndim(x)))
    463                 else:
--> 464                     if K.ndim(x) != spec.ndim:
    465                         raise ValueError('Input ' + str(input_index) +
    466                                          ' is incompatible with layer ' +

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/keras/backend/mxnet_backend.py in ndim(x)
    632     ```
    633     """
--> 634     s = shape(x)
    635     if s is None:
    636         return 0

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/keras/backend/mxnet_backend.py in shape(x)
    577     #       return tuple([0 if x is None else x for x in x._keras_shape])
    578     if isinstance(x, KerasSymbol):
--> 579         return x.get_shape()
    580     else:
    581         return None

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/keras/backend/mxnet_backend.py in get_shape(self)
    256             return self.tensor.shape
    257         else:
--> 258             _, out_shape, _ = self.symbol.infer_shape_partial()
    259             return out_shape[0]
    260

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/symbol.py in infer_shape_partial(self, *args, **kwargs)
   1048             The order is same as the order of list_auxiliary_states().
   1049         """
-> 1050         return self._infer_shape_impl(True, *args, **kwargs)
   1051
   1052     def _infer_shape_impl(self, partial, *args, **kwargs):

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/symbol.py in _infer_shape_impl(self, partial, *args, **kwargs)
   1105             ctypes.byref(aux_shape_ndim),
   1106             ctypes.byref(aux_shape_data),
-> 1107             ctypes.byref(complete)))
   1108         if complete.value != 0:
   1109             arg_shapes = [

~/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/base.py in check_call(ret)
    127     """
    128     if ret != 0:
--> 129         raise MXNetError(py_str(_LIB.MXGetLastError()))
    130
    131 if sys.version_info[0] < 3:

MXNetError: Error in operator pooling0: [21:10:59] src/operator/./pooling-inl.h:214: Check failed: param_.kernel[0] <= dshape[2] + 2 * param_.pad[0] kernel size (3) exceeds input (0 padded to 0)

Stack trace returned 10 entries:
[bt] (0) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0xec23c) [0x7fec5a44123c]
[bt] (1) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x1170ca2) [0x7fec5b4c5ca2]
[bt] (2) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0xf90817) [0x7fec5b2e5817]
[bt] (3) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x16e9531) [0x7fec5ba3e531]
[bt] (4) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x16ead42) [0x7fec5ba3fd42]
[bt] (5) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x16eb686) [0x7fec5ba40686]
[bt] (6) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0x16d4e88) [0x7fec5ba29e88]
[bt] (7) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0xe049fe) [0x7fec5b1599fe]
[bt] (8) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(+0xe0732e) [0x7fec5b15c32e]
[bt] (9) /home/ubuntu/anaconda3/envs/mxnet/lib/python3.5/site-packages/mxnet/libmxnet.so(MXSymbolInferShape+0x156f) [0x7fec5b154d2f]

@sandeep-krishnamurthy
Copy link

Will look in to this.

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

3 participants