26hzhang / neural_sequence_labeling

A TensorFlow implementation of Neural Sequence Labeling model, which is able to tackle sequence labeling tasks such as POS Tagging, Chunking, NER, Punctuation Restoration and etc.
MIT License
234 stars 47 forks source link

Error when run inference #13

Closed tringn closed 4 years ago

tringn commented 5 years ago

Hi @IsaacChanghau, Thanks for your great work. I have an issue when running inference. I restore the checkpoint and predict tag for the input sentence. But the error occurs. Can you help me?


2019-06-04 10:58:58.520794: I tensorflow/stream_executor/dso_loader.cc:152] successfully opened CUDA library libcublas.so.10.0 locally
2019-06-04 10:58:58.700894: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at conv_ops.cc:437 : Invalid argument: Computed output size would be negative: -1 [input_size: 3, effective_filter_size: 5, stride: 1]
2019-06-04 10:58:58.700985: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at conv_ops.cc:437 : Invalid argument: Computed output size would be negative: -1 [input_size: 3, effective_filter_size: 5, stride: 1]
Computed output size would be negative: -1 [input_size: 3, effective_filter_size: 5, stride: 1]
     [[node embeddings/multi_conv1d/conv1d_1/Conv2D (defined at /home/erv-trinn/workspace/keyphrase_extraction/neural_sequence_labeling/models/nns.py:56) ]]
     [[node project/dense/BiasAdd (defined at /home/erv-trinn/workspace/keyphrase_extraction/neural_sequence_labeling/models/blstm_cnn_crf_model.py:117) ]]

Caused by op 'embeddings/multi_conv1d/conv1d_1/Conv2D', defined at:
  File "predict_text.py", line 106, in <module>
    model = SequenceLabelModel(config)
  File "/home/erv-trinn/workspace/keyphrase_extraction/neural_sequence_labeling/models/blstm_cnn_crf_model.py", line 13, in __init__
    super(SequenceLabelModel, self).__init__(config)
  File "/home/erv-trinn/workspace/keyphrase_extraction/neural_sequence_labeling/models/base_model.py", line 16, in __init__
    self._build_embedding_op()
  File "/home/erv-trinn/workspace/keyphrase_extraction/neural_sequence_labeling/models/blstm_cnn_crf_model.py", line 68, in _build_embedding_op
    drop_rate=self.drop_rate, is_train=self.is_train)
  File "/home/erv-trinn/workspace/keyphrase_extraction/neural_sequence_labeling/models/nns.py", line 69, in multi_conv1d
    scope="conv1d_{}".format(i))
  File "/home/erv-trinn/workspace/keyphrase_extraction/neural_sequence_labeling/models/nns.py", line 56, in conv1d
    xxc = tf.nn.conv2d(in_, filter_, strides, padding) + bias
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1026, in conv2d
    data_format=data_format, dilations=dilations, name=name)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
    op_def=op_def)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
    op_def=op_def)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1801, in __init__
    self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Computed output size would be negative: -1 [input_size: 3, effective_filter_size: 5, stride: 1]
     [[node embeddings/multi_conv1d/conv1d_1/Conv2D (defined at /home/erv-trinn/workspace/keyphrase_extraction/neural_sequence_labeling/models/nns.py:56) ]]
     [[node project/dense/BiasAdd (defined at /home/erv-trinn/workspace/keyphrase_extraction/neural_sequence_labeling/models/blstm_cnn_crf_model.py:117) ]]```
CelineChen95 commented 4 years ago

How to run inference ? i haven't seen the inference script?

tringn commented 4 years ago

Hi @CelineChen95, You can use model = SequenceLabelModel(config) model.restore_last_session() and model.inference(your_sentence)