macanv / BERT-BiLSTM-CRF-NER

Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning And private Server services
https://github.com/macanv/BERT-BiLSMT-CRF-NER
4.69k stars 1.25k forks source link

求助,部署成服务之后未成功ready and listening 报错Process BertWorker-3:Requested return tensor 'pred_ids:0' not found in graph def #278

Closed tian231825 closed 4 years ago

tian231825 commented 4 years ago

I:SINK:[i:_ru:372]:send config client b'18bc8f81-483b-4e10-82b1-6f7b807 97564' I:VENTILATOR:[__i:_ru:199]:new config request req id: 0 client: b'264f9f c0-7ecd-4919-8309-d6c2f017a491' I:SINK:[i:_ru:372]:send config client b'264f9fc0-7ecd-4919-8309-d6c2f01 7a491' I:VENTILATOR:[i:_ru:199]:new config request req id: 0 client: b'094e13 8e-c572-4010-931f-56b88e49f12d' I:SINK:[__i:_ru:372]:send config client b'094e138e-c572-4010-931f-56b88e4 9f12d' I:VENTILATOR:[i:_ru:199]:new config request req id: 0 client: b'b27ab8 74-a441-4f4d-a682-067ea3f83c41' I:SINK:[i:_ru:372]:send config client b'b27ab874-a441-4f4d-a682-067ea3f 83c41' I:VENTILATOR:[__i:_ru:199]:new config request req id: 0 client: b'696114 45-d6d1-45a0-ae73-bacd30ceee2a' I:SINK:[i:_ru:372]:send config client b'69611445-d6d1-45a0-ae73-bacd30c eee2a'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/anaconda3/lib/python3.6/multiprocessing/process.py", line 258, in _ bootstrap self.run() File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 487, in run self._run() File "/home/junruit/.local/lib/python3.6/site-packages/zmq/decorators.py", lin e 75, in wrapper return func(*args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/zmq_de cor.py", line 27, in wrapper return func(args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 505, in _run for r in estimator.predict(input_fn=self.input_fn_builder(receivers, tf), yi eld_single_examples=False): File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow_estimator/py thon/estimator/estimator.py", line 611, in predict features, None, model_fn_lib.ModeKeys.PREDICT, self.config) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow_estimator/py thon/estimator/estimator.py", line 1112, in _call_model_fn model_fn_results = self._model_fn(features=features, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 441, in ner_model_fn pred_ids = tf.import_graph_def(graph_def, name='', input_map=input_map, retu rn_elements=['pred_ids:0']) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/util/ deprecation.py", line 507, in new_func return func(args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/frame work/importer.py", line 430, in import_graph_def raise ValueError(str(e)) ValueError: Requested return tensor 'pred_ids:0' not found in graph def Process BertWorker-5: Traceback (most recent call last): File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/frame work/importer.py", line 426, in import_graph_def graph._c_graph, serialized, options) # pylint: disable=protected-access tensorflow.python.framework.errors_impl.InvalidArgumentError: Requested return t ensor 'pred_ids:0' not found in graph def

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/anaconda3/lib/python3.6/multiprocessing/process.py", line 258, in _ bootstrap self.run() File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 487, in run self._run() File "/home/junruit/.local/lib/python3.6/site-packages/zmq/decorators.py", lin e 75, in wrapper return func(*args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/zmq_de cor.py", line 27, in wrapper return func(args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 505, in _run for r in estimator.predict(input_fn=self.input_fn_builder(receivers, tf), yi eld_single_examples=False): File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow_estimator/py thon/estimator/estimator.py", line 611, in predict features, None, model_fn_lib.ModeKeys.PREDICT, self.config) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow_estimator/py thon/estimator/estimator.py", line 1112, in _call_model_fn model_fn_results = self._model_fn(features=features, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 441, in ner_model_fn pred_ids = tf.import_graph_def(graph_def, name='', input_map=input_map, retu rn_elements=['pred_ids:0']) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/util/ deprecation.py", line 507, in new_func return func(args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/frame work/importer.py", line 430, in import_graph_def raise ValueError(str(e)) ValueError: Requested return tensor 'pred_ids:0' not found in graph def Process BertWorker-4: Traceback (most recent call last): File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/frame work/importer.py", line 426, in import_graph_def graph._c_graph, serialized, options) # pylint: disable=protected-access tensorflow.python.framework.errors_impl.InvalidArgumentError: Requested return t ensor 'pred_ids:0' not found in graph def

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/anaconda3/lib/python3.6/multiprocessing/process.py", line 258, in _ bootstrap self.run() File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 487, in run self._run() File "/home/junruit/.local/lib/python3.6/site-packages/zmq/decorators.py", lin e 75, in wrapper return func(*args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/zmq_de cor.py", line 27, in wrapper return func(args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 505, in _run for r in estimator.predict(input_fn=self.input_fn_builder(receivers, tf), yi eld_single_examples=False): File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow_estimator/py thon/estimator/estimator.py", line 611, in predict features, None, model_fn_lib.ModeKeys.PREDICT, self.config) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow_estimator/py thon/estimator/estimator.py", line 1112, in _call_model_fn model_fn_results = self._model_fn(features=features, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 441, in ner_model_fn pred_ids = tf.import_graph_def(graph_def, name='', input_map=input_map, retu rn_elements=['pred_ids:0']) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/util/ deprecation.py", line 507, in new_func return func(args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/frame work/importer.py", line 430, in import_graph_def raise ValueError(str(e)) ValueError: Requested return tensor 'pred_ids:0' not found in graph def Process BertWorker-6: Traceback (most recent call last): File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/frame work/importer.py", line 426, in import_graph_def graph._c_graph, serialized, options) # pylint: disable=protected-access tensorflow.python.framework.errors_impl.InvalidArgumentError: Requested return t ensor 'pred_ids:0' not found in graph def

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/anaconda3/lib/python3.6/multiprocessing/process.py", line 258, in _ bootstrap self.run() File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 487, in run self._run() File "/home/junruit/.local/lib/python3.6/site-packages/zmq/decorators.py", lin e 75, in wrapper return func(*args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/zmq_de cor.py", line 27, in wrapper return func(args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 505, in _run for r in estimator.predict(input_fn=self.input_fn_builder(receivers, tf), yi eld_single_examples=False): File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow_estimator/py thon/estimator/estimator.py", line 611, in predict features, None, model_fn_lib.ModeKeys.PREDICT, self.config) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow_estimator/py thon/estimator/estimator.py", line 1112, in _call_model_fn model_fn_results = self._model_fn(features=features, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 441, in ner_model_fn pred_ids = tf.import_graph_def(graph_def, name='', input_map=input_map, retu rn_elements=['pred_ids:0']) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/util/ deprecation.py", line 507, in new_func return func(args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/tensorflow/python/frame work/importer.py", line 430, in import_graph_def raise ValueError(str(e)) ValueError: Requested return tensor 'pred_ids:0' not found in graph def Process BertWorker-3: ^CTraceback (most recent call last): File "/home/junruit/.local/bin/bert-base-serving-start", line 10, in Process BertSink-2: sys.exit(start_server()) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/runs/init .py", line 19, in start_server server.join() File "/opt/anaconda3/lib/python3.6/threading.py", line 1056, in join self._wait_for_tstate_lock() File "/opt/anaconda3/lib/python3.6/threading.py", line 1072, in _wait_for_tsta telock elif lock.acquire(block, timeout): KeyboardInterrupt Traceback (most recent call last): File "/opt/anaconda3/lib/python3.6/multiprocessing/process.py", line 258, in bootstrap self.run() File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 293, in run self._run() File "/home/junruit/.local/lib/python3.6/site-packages/zmq/decorators.py", lin e 75, in wrapper return func(*args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/zmq/decorators.py", lin e 75, in wrapper return func(*args, *kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/zmq/decorators.py", lin e 75, in wrapper return func(args, kwargs) File "/home/junruit/.local/lib/python3.6/site-packages/bert_base/server/init .py", line 320, in _run socks = dict(poller.poll()) File "/home/junruit/.local/lib/python3.6/site-packages/zmq/sugar/poll.py", lin e 99, in poll return zmq_poll(self.sockets, timeout=timeout) File "zmq/backend/cython/_poll.pyx", line 123, in zmq.backend.cython._poll.zmq _poll File "zmq/backend/cython/checkrc.pxd", line 12, in zmq.backend.cython.checkrc. _check_rc KeyboardInterrupt ^CException ignored in: <module 'threading' from '/opt/anaconda3/lib/python3.6/t hreading.py'> Traceback (most recent call last): File "/opt/anaconda3/lib/python3.6/threading.py", line 1294, in _shutdown t.join() File "/opt/anaconda3/lib/python3.6/threading.py", line 1056, in join self._wait_for_tstate_lock() File "/opt/anaconda3/lib/python3.6/threading.py", line 1072, in _wait_for_tsta te_lock elif lock.acquire(block, timeout): KeyboardInterrupt

tian231825 commented 4 years ago

解决了,把freeze里面的关于pred_ids的注释去掉并且将其加入 tmp_g = graph_util.convert_variables_to_constants(sess, graph.as_graph_def(), ['pred_prob','pred_ids']) 然后生成的pb文件就能成功使用了