Closed smallduckpro closed 8 months ago
我跟你一样的错误,一直加载失败,我提前下好了zip,放到指定的路径,还是显示加载失败。而且下面那个也说没有AbstractRNNCell属性。搞不懂怎么回事
tf的建议版本是 https://github.com/hankcs/HanLP/blob/dfd8d5eb7428f1097f68a2a70b555e65ec7b8f76/setup.py#L20
其他版本未经过测试不保证正常运行。
Workaround: 把tf降级到2.15
Describe the bug 在加载模型时报错,具体见输出的errorlog
Code to reproduce the issue
Describe the current behavior 有模型的下载过程,并且能下载成功,但是加载模型的时候报错,似乎是TensorFlow的问题
Expected behavior 在运行COARSE_ELECTRA_SMALL_ZH和MSRA_NER_ELECTRA_SMALL_ZH模型的时候能够正常使用,但是更换其他模型后报错了
System information
Other info / logs ================================ERROR LOG BEGINS================================ OS: Windows-10-10.0.19045-SP0 Python: 3.11.5 PyTorch: 2.2.1+cpu TensorFlow: 2.16.1 HanLP: 2.1.0-beta.57 Traceback (most recent call last): File "D:\WorkSpace\Python\deeplearning\Hanlp\main.py", line 38, in
NER_Local_test()
File "D:\WorkSpace\Python\deeplearning\Hanlp\main.py", line 28, in NER_Local_test
ner = hanlp.load(hanlp.pretrained.ner.CONLL03_NER_BERT_BASE_CASED_EN)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp__init__.py", line 43, in load
return load_from_meta_file(save_dir, 'meta.json', verbose=verbose, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp\utils\component_util.py", line 186, in load_from_meta_file
raise e from None
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp\utils\component_util.py", line 99, in load_from_meta_file
obj: Component = object_from_classpath(cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp_common\reflection.py", line 27, in object_from_classpath
classpath = str_to_type(classpath)
^^^^^^^^^^^^^^^^^^^^^^
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp_common\reflection.py", line 44, in str_to_type
cls = getattr(importlib.import_module(module_name), class_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ProgramData\anaconda3\Lib\importlib__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp\components\ner\ner_tf.py", line 13, in
from hanlp.components.taggers.ngram_conv.ngram_conv_tagger import NgramConvTaggerTF
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp\components\taggers\ngram_conv\ngram_conv_tagger.py", line 10, in
from hanlp.components.taggers.tagger_tf import TaggerComponent
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp\components\taggers\tagger_tf.py", line 10, in
from hanlp.layers.crf.crf_layer_tf import CRF, CRFLoss, CRFWrapper
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp\layers\crf\crf_layer_tf.py", line 18, in
from hanlp.layers.crf.crf_tf import crf_decode, crf_log_likelihood
File "D:\ProgramData\anaconda3\Lib\site-packages\hanlp\layers\crf\crf_tf.py", line 366, in
class CrfDecodeForwardRnnCell(tf.keras.layers.AbstractRNNCell):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'keras._tf_keras.keras.layers' has no attribute 'AbstractRNNCell'
=================================ERROR LOG ENDS=================================