-
Notifications
You must be signed in to change notification settings - Fork 6.7k
error in bind model after load checkpoint in example named_entity_recognition #11859
Description
I tried the implementation of named entity recognition in MXNet example:
https://github.com/apache/incubator-mxnet/tree/master/example/named_entity_recognition
After the train process, i reopen the model saved in the checkpoint file (to be able to do a prediction on new data)
def load_model(model_prefix,epoch_n):
ctx = mx.cpu()
sym, arg_params, aux_params = mx.model.load_checkpoint(model_prefix, epoch_n)
mod = mx.mod.Module(symbol=sym, context=ctx,data_names=['sentences','characters'],
label_names=[('seq_label')])
provide_data = [mx.io.DataDesc(name='sentences', shape=(128,40), layout='NT'),
mx.io.DataDesc(name='characters', shape=(128,40,5), layout='NT')]
provide_label=[mx.io.DataDesc(name='seq_label', shape=(128, 40), layout='NT')]
mod.bind(data_shapes=provide_data,label_shapes=provide_label,for_training=False)
mod.set_params(arg_params, aux_params)
return mod
But when execute model bind i have this error:
****************************************************
File "c:\ezioDev\python\NER_MXNet\ner.py", line 144, in predict_model
mod = load_model('results/checkpoint', 1,data_iter)
File "c:\ezioDev\python\NER_MXNet\ner.py", line 116, in load_model
mod.bind(data_shapes=provide_data,label_shapes=provide_label,for_training=False)
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\mxnet\module\module.py", line 430, in bind
state_names=self._state_names)
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\mxnet\module\executor_group.py", line 265, in init
self.bind_exec(data_shapes, label_shapes, shared_group)
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\mxnet\module\executor_group.py", line 361, in bind_exec
shared_group))
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\mxnet\module\executor_group.py", line 639, in _bind_ith_exec
shared_buffer=shared_data_arrays, **input_shapes)
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\mxnet\symbol\symbol.py", line 1519, in simple_bind
raise RuntimeError(error_msg)
RuntimeError: simple_bind error. Arguments:
characters: (128, 40, 5)
sentences: (128, 40)
seq_label: (128, 40)
Error in operator char_embed2: [21:36:39] c:\projects\mxnet-distro-win\mxnet-build\src\operator\tensor./matrix_op-inl.h:187: Check failed: oshape.Size() == dshape.Size() (614400 vs. 640000) Target shape size is different to source. Target: [128,1,16,12,25]
Source: [128,40,5,25]
I use the same data_shapes of input data in train step.
I also used shape of one sentence : 1 instead of 128 as a batch_size; nothing has changed. :-(
Problem seems to be similar this :
https://discuss.mxnet.io/t/nlp-prediction-using-a-cnn-pretrained-model/280
I tried the suggested solution but it does not work.
I Used Python3, error happened both mac os (sierra 10.13) and windows 10
Help me!!! please!!!!