Error during running the pretrained model
acDante opened this issue · 3 comments
Hello, I encountered the following error when trying to use the provided command for prediction with pre-trained models:
I used the following command:
$ python main.py predict --data_path ./data/preprocessed.txt --model_dir pre-trained/conll05/ensemble/run0 --model_name deepatt --vocab_path ./pre-trained/conll05/ensemble/dict/word_dict0 ./pre-trained/conll05/ensemble/dict/label_dict --device_list 0 --emb_path ./data/glove/glove.6B.100d.txt
and got this error information:
Traceback (most recent call last):
File "main.py", line 895, in
predict(parsed_args)
File "main.py", line 616, in predict
as_iterable=True)
File "/Users/xiaotang/Documents/SRL/Tagger/venv/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func
return func(*args, **kwargs)
File "/Users/xiaotang/Documents/SRL/Tagger/venv/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 670, in predict
iterate_batches=iterate_batches)
File "/Users/xiaotang/Documents/SRL/Tagger/venv/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 967, in _infer_model
features = self._get_features_from_input_fn(input_fn)
File "/Users/xiaotang/Documents/SRL/Tagger/venv/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 947, in _get_features_from_input_fn
result = input_fn()
File "/Users/xiaotang/Documents/SRL/Tagger/data/plain_text.py", line 43, in _decode_batch_input_fn
outputs = preprocess_fn(inputs)
File "/Users/xiaotang/Documents/SRL/Tagger/data/plain_text.py", line 175, in
lambda x: convert_text(x, vocab, params))
File "/Users/xiaotang/Documents/SRL/Tagger/data/plain_text.py", line 158, in convert_text
emb[i] = params.embedding[word]
ValueError: could not broadcast input array from shape (100) into shape (128)
Is there something wrong in my command ? How could I run prediction with pretrained model ?
You forgot to add the model specific hyper-parameters. You should add --model_params="num_hidden_layers=10,feature_size=100,hidden_size=200,filter_size=800"
to override default hyper-parameters.
Thanks a lot ! It works now :-)))