Closed ZhuoxueQAQ closed 4 years ago
问题 +1
解决了,我是通过 git clone https://github.com/macanv/BERT-BiLSTM-CRF-NER cd BERT-BiLSTM-CRF-NER/ python3 setup.py install 安装,导致上述问题
解决办法: 执行 pip install bert-base==0.0.7 -i https://pypi.python.org/simple 安装即可
想问一下具体什么原因?为啥执行 pip install bert-base==0.0.7 -i https://pypi.python.org/simple就解决了?
猜测:是BERT-BiLSTM-CRF-NER/bert_base/server目录下的init.py里的classification_model_fn方法里的segment_id特征这个变量导致的吗?
segment_ids=features["input_type_ids"] input_map = {"input_ids": input_ids, "input_mask": input_mask,"segment_ids":segment_ids}
用freeze_graph.py在model_dir目录下生成classification_model.pb文件,即可解决该问题
I:?[35mVENTILATOR?[0m:lodding classification predict, could take a while... I:?[35mVENTILATOR?[0m:contain 0 labels:dict_values(['0', '1']) 2020-01-14 21:09:35.241239: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic lib rary cudart64_100.dll pb_file exits F:\学习资料\毕设\code\bert-master\bert-master\output\classification_model.pb I:?[35mVENTILATOR?[0m:optimized graph is stored at: F:\学习资料\毕设\code\bert-master\bert-master\output\classification_mod el.pb I:?[35mVENTILATOR?[0m:bind all sockets I:?[35mVENTILATOR?[0m:open 8 ventilator-worker sockets, tcp://127.0.0.1:64609,tcp://127.0.0.1:64610,tcp://127.0.0.1:64611,t cp://127.0.0.1:64612,tcp://127.0.0.1:64613,tcp://127.0.0.1:64614,tcp://127.0.0.1:64615,tcp://127.0.0.1:64616 I:?[35mVENTILATOR?[0m:start the sink 2020-01-14 21:09:37.534152: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic lib rary cudart64_100.dll I:?[32mSINK?[0m:ready I:?[35mVENTILATOR?[0m:get devices I:?[35mVENTILATOR?[0m:device map: worker 0 -> gpu 0 2020-01-14 21:09:39.903511: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic lib rary cudart64100.dll I:?[33mWORKER-0?[0m:use device gpu: 0, load graph from F:\学习资料\毕设\code\bert-master\bert-master\output\classification model.pb WARNING:tensorflow:From d:\anaconda\lib\site-packages\bert_base-0.0.9-py3.7.egg\bert_base\server\helper.py:161: The name tf .logging.set_verbosity is deprecated. Please use tf.compat.v1.logging.set_verbosity instead.
WARNING:tensorflow:From d:\anaconda\lib\site-packages\bert_base-0.0.9-py3.7.egg\bert_base\server\helper.py:161: The name tf .logging.ERROR is deprecated. Please use tf.compat.v1.logging.ERROR instead. Process BertWorker-3: Traceback (most recent call last): File "D:\Anaconda\lib\multiprocessing\process.py", line 297, in _bootstrap self.run() File "d:\anaconda\lib\site-packages\bert_base-0.0.9-py3.7.egg\bert_base\server__init.py", line 490, in run self._run() File "d:\anaconda\lib\site-packages\zmq\decorators.py", line 75, in wrapper return func(*args, *kwargs) File "d:\anaconda\lib\site-packages\bert_base-0.0.9-py3.7.egg\bert_base\server\zmq_decor.py", line 27, in wrapper return func(args, kwargs) File "d:\anaconda\lib\site-packages\bert_base-0.0.9-py3.7.egg\bert_base\server__init__.py", line 508, in _run for r in estimator.predict(input_fn=self.input_fn_builder(receivers, tf), yield_single_examples=False): File "d:\anaconda\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 622, in predict features, None, ModeKeys.PREDICT, self.config) File "d:\anaconda\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1149, in _call_model_fn model_fn_results = self._model_fn(features=features, kwargs) File "d:\anaconda\lib\site-packages\bert_base-0.0.9-py3.7.egg\bert_base\server\init_.py", line 466, in classification model_fn pred_probs = tf.import_graph_def(graph_def, name='', input_map=input_map, return_elements=['pred_prob:0']) File "d:\anaconda\lib\site-packages\tensorflow_core\python\util\deprecation.py", line 507, in new_func return func(*args, **kwargs) File "d:\anaconda\lib\site-packages\tensorflow_core\python\framework\importer.py", line 405, in import_graph_def producer_op_list=producer_op_list) File "d:\anaconda\lib\site-packages\tensorflow_core\python\framework\importer.py", line 535, in _import_graph_def_interna l ', '.join(missing_unused_input_keys)) ValueError: Attempted to map inputs that were not found in graph_def: [segment_ids:0]