在使用语义角色标注分析功能的时候,使用如下python代码:
print(’===HanLP 语义角色标注分析=====================’)
tok = hanlp.load(hanlp.pretrained.tok.FINE_ELECTRA_SMALL_ZH)
tokResult = tok(sentence4)
sdp = hanlp.load(hanlp.pretrained.sdp.SEMEVAL16_NEWS_BIAFFINE_ZH)
print(‘模型载入成功:SEMEVAL16_NEWS_BIAFFINE_ZH’)
sdpResult = sdp(tokResult)
print(sdpResult)
=======================================
运行之后,系统出错,错误日志如下:
===HanLP 语义角色标注分析=====================
2022-04-07 11:59:10.041830: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cudart64_110.dll’; dlerror: cudart64_110.dll not found
2022-04-07 11:59:10.042593: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2022-04-07 11:59:14.804092: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2022-04-07 11:59:14.810581: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: ChengXiaobin
2022-04-07 11:59:14.810801: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: ChengXiaobin
2022-04-07 11:59:14.851886: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
模型载入成功:SEMEVAL16_NEWS_BIAFFINE_ZH
2022-04-07 11:59:19.098615: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2)
2022-04-07 11:59:19.137981: W tensorflow/core/framework/op_kernel.cc:1680] Invalid argument: ValueError: not enough values to unpack (expected 4, got 3)
Traceback (most recent call last):
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\ops\script_ops.py”, line 249, in call
ret = func(*args)
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\autograph\impl\api.py”, line 645, in wrapper
return func(*args, **kwargs)
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py”, line 892, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\transform\conll_tf.py”, line 149, in generator
corpus = list(x for x in (samples() if callable(samples) else samples))
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\transform\conll_tf.py”, line 149, in
corpus = list(x for x in (samples() if callable(samples) else samples))
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\common\transform_tf.py”, line 157, in generator
yield from samples
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\transform\conll_tf.py”, line 727, in inputs_to_samples
form, cpos, head, deprel = sample[0]
ValueError: not enough values to unpack (expected 4, got 3)
Traceback (most recent call last):
File “D:/py_proj_53git/kfai_nlp/scripts/research/rs_hanlp.py”, line 147, in
sdpResult = sdp(tokResult)
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\common\component.py”, line 36, in call
return self.predict(*args, **kwargs)
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\common\keras_component.py”, line 432, in predict
for idx, batch in enumerate(dataset):
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\data\ops\iterator_ops.py”, line 761, in next
return self._next_internal()
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\data\ops\iterator_ops.py”, line 747, in _next_internal
output_shapes=self._flat_output_shapes)
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\ops\gen_dataset_ops.py”, line 2727, in iterator_get_next
_ops.raise_from_not_ok_status(e, name)
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\framework\ops.py”, line 6941, in raise_from_not_ok_status
six.raise_from(core._status_to_exception(e.code, message), None)
File “”, line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: ValueError: not enough values to unpack (expected 4, got 3)
Traceback (most recent call last):
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\ops\script_ops.py”, line 249, in call
ret = func(*args)
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\autograph\impl\api.py”, line 645, in wrapper
return func(*args, **kwargs)
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py”, line 892, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\transform\conll_tf.py”, line 149, in generator
corpus = list(x for x in (samples() if callable(samples) else samples))
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\transform\conll_tf.py”, line 149, in
corpus = list(x for x in (samples() if callable(samples) else samples))
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\common\transform_tf.py”, line 157, in generator
yield from samples
File “D:\py_proj_53git\kfai_nlp\venv\lib\site-packages\hanlp\transform\conll_tf.py”, line 727, in inputs_to_samples
form, cpos, head, deprel = sample[0]
ValueError: not enough values to unpack (expected 4, got 3)
[[{{node PyFunc}}]] [Op:IteratorGetNext]
Process finished with exit code 1
这个错误同样出现在SEMEVAL16_TEXT_BIAFFINE_ZH这个模型上。目前只有SEMEVAL16_ALL_ELECTRA_SMALL_ZH模型是可以使用的(_EN的没有去测)
请问这个问题是什么原因,看错误是参数缺失了。