mxnet-model-gallery icon indicating copy to clipboard operation
mxnet-model-gallery copied to clipboard

RuntimeError: prob_label is not presented

Open anboqing opened this issue 8 years ago • 1 comments

#Hi,

I got an RuntimeError: prob_label is not presented when I run [http://mxnet.io/tutorials/python/predict_imagenet.html](Example : Predict with pretrained model) with pretrained model https://github.com/dmlc/mxnet-model-gallery/blob/master/imagenet-1k-nin.md.

first , I load pretrained model follow the tutorial:

import mxnet as mx
sym, arg_params, aux_params = mx.model.load_checkpoint('nin', 0)

I found 'prob_label' in sym.list_arguments() but it is not exists in 'arg_params'

when I create a model for this model on GPU 0 like this:

mod = mx.mod.Module(symbol=sym, context=mx.gpu())
mod.bind(for_training=False, data_shapes=[('data', (1,3,224,224))])
mod.set_params(arg_params, aux_params)

the error occurs at mod.set_params(arg_params, aux_params) ,

Traceback (most recent call last):
  File "loadmodel.py", line 7, in <module>
    mod.set_params(arg_params, aux_params,allow_missing=False)
  File "/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet/module/base_module.py", line 483, in set_params
    allow_missing=allow_missing, force_init=force_init)
  File "/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet/module/module.py", line 198, in init_params
    _impl(name, arr, arg_params)
  File "/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet/module/module.py", line 191, in _impl
    raise RuntimeError("%s is not presented" % name)
RuntimeError: prob_label is not presented


how can I fix this?

anboqing avatar Nov 29 '16 12:11 anboqing

I met this problem and fix it by adding arg_params['prob_label'] = mx.nd.array([0]) before mod.set_params(arg_params, aux_params)

burness avatar Dec 08 '16 07:12 burness