Error running deep learning image classification example with Mxnet library on Python
<p>I am trying to run the <a href="https://github.com/dmlc/mxnet/blob/master/example/notebooks/predict-with-pretrained-model.ipynb" rel="nofollow">this image classification example</a> that uses <a href="https://github.com/dmlc/mxnet" rel="nofollow">Mxnet library</a> in python and the pre-trained deep learning model Inception-BN. The execution throws and error on this line: <code>prob = model.predict(batch)[0]</code> with the error message:</p>

<pre><code>MXNetError: InferShape Error in ch_concat_3c_chconcat: [14:35:56] src/operator/./concat-inl.h:152: Check failed: (dshape[j]) == (tmp[j]) Incorrect shape[2]: (1,320,15,15). (first input shape: (1,576,14,14))
</code></pre>

<p>I tried downloading the Inception-BN model again to make sure it was up to date but it didn't make a difference. I do suspect the problem could be on line: <code>model = mx.model.FeedForward.load(prefix, num_round, ctx=mx.gpu(), numpy_batch_size=1)</code> where I had to change <strong>gpu</strong> for <strong>cpu</strong> since my server is not equiped with a gpu. Nevertheless the error doesn't seem to point on that direction.</p>

<p>Any idea how to fix it? Is using a cpu instead of a gpu a problem other than a lower performance?</p>

<p>Finally here is the complete error information:</p>

<pre><code>---------------------------------------------------------------------------
MXNetError                                Traceback (most recent call last)
&lt;ipython-input-7-98e51e4226e1&gt; in &lt;module&gt;()
      1 # Get prediction probability of 1000 classes from model
----&gt; 2 prob = model.predict(batch)[0]
      3 # Argsort, get prediction index from largest prob to lowest
      4 pred = np.argsort(prob)[::-1]
      5 # Get top1 label

/users/CREATE/olb/mxnet/python/mxnet/model.pyc in predict(self, X, num_batch, return_data, reset)
    589         data_shapes = X.provide_data
    590         data_names = [x[0] for x in data_shapes]
--&gt; 591         self._init_predictor(data_shapes)
    592         batch_size = X.batch_size
    593         data_arrays = [self._pred_exec.arg_dict[name] for name in data_names]

/users/CREATE/olb/mxnet/python/mxnet/model.pyc in _init_predictor(self, input_shapes)
    520         # for now only use the first device
    521         pred_exec = self.symbol.simple_bind(
--&gt; 522             self.ctx[0], grad_req='null', **dict(input_shapes))
    523         pred_exec.copy_params_from(self.arg_params, self.aux_params)
    524 

/users/CREATE/olb/mxnet/python/mxnet/symbol.pyc in simple_bind(self, ctx, grad_req, type_dict, **kwargs)
    623         if type_dict is None:
    624             type_dict = {k: mx_real_t for k in self.list_arguments()}
--&gt; 625         arg_shapes, _, aux_shapes = self.infer_shape(**kwargs)
    626         arg_types, _, aux_types = self.infer_type(**type_dict)
    627         if arg_shapes == None or arg_types == None:

/users/CREATE/olb/mxnet/python/mxnet/symbol.pyc in infer_shape(self, *args, **kwargs)
    410             The order is in the same order as list_auxiliary()
    411         """
--&gt; 412         return self._infer_shape_impl(False, *args, **kwargs)
    413 
    414     def infer_shape_partial(self, *args, **kwargs):

/users/CREATE/olb/mxnet/python/mxnet/symbol.pyc in _infer_shape_impl(self, partial, *args, **kwargs)
    470             ctypes.byref(aux_shape_ndim),
    471             ctypes.byref(aux_shape_data),
--&gt; 472             ctypes.byref(complete)))
    473         if complete.value != 0:
    474             arg_shapes = [

/users/CREATE/olb/mxnet/python/mxnet/base.pyc in check_call(ret)
     75     """
     76     if ret != 0:
---&gt; 77         raise MXNetError(py_str(_LIB.MXGetLastError()))
     78 
     79 def c_str(string):

MXNetError: InferShape Error in ch_concat_3c_chconcat: [14:35:56] src/operator/./concat-inl.h:152: Check failed: (dshape[j]) == (tmp[j]) Incorrect shape[2]: (1,320,15,15). (first input shape: (1,576,14,14))
</code></pre>