根据例子运行句法分析训练错误

运行一下代码

-- coding:utf-8 --

Author: hankcs

Date: 2019-12-28 18:33

from hanlp.components.parsers.biaffine_parser import BiaffineDependencyParser
from hanlp.datasets.parsing.ctb import CTB7_DEP_TRAIN, CTB7_DEP_VALID, CTB7_DEP_TEST, CIP_W2V_100_CN

save_dir = ‘data/model/dep/biaffine_ctb7’
parser = BiaffineDependencyParser()
parser.fit(CTB7_DEP_TRAIN, CTB7_DEP_VALID, save_dir,
pretrained_embed={‘class_name’: ‘HanLP>Word2VecEmbedding’,
‘config’: {
‘trainable’: False,
‘embeddings_initializer’: ‘zero’,
‘filepath’: CIP_W2V_100_CN,
‘expand_vocab’: True,
‘lowercase’: True,
‘normalize’: True,
}},
)
parser.load(save_dir)
sentence = [(‘中国’, ‘NR’), (‘批准’, ‘VV’), (‘设立’, ‘VV’), (‘外商’, ‘NN’), (‘投资’, ‘NN’), (‘企业’, ‘NN’), (‘逾’, ‘VV’),
(‘三十万’, ‘CD’), (‘家’, ‘M’)]
print(parser.predict(sentence))
parser.evaluate(CTB7_DEP_TEST, save_dir)

错误结果:
Traceback (most recent call last):
File “dep.py”, line 17, in
‘normalize’: True,
File “/home/FlStuGrp/ST12AStu/anaconda3/envs/hanlp/lib/python3.6/site-packages/hanlp/components/parsers/biaffine_parser.py”, line 80, in fit
return super().fit(**merge_locals_kwargs(locals(), kwargs))
File “/home/FlStuGrp/ST12AStu/anaconda3/envs/hanlp/lib/python3.6/site-packages/hanlp/common/component.py”, line 341, in fit
callbacks = self.build_callbacks(save_dir, logger, **self.config)
File “/home/FlStuGrp/ST12AStu/anaconda3/envs/hanlp/lib/python3.6/site-packages/hanlp/components/parsers/biaffine_parser.py”, line 226, in build_callbacks
c.set_params(params)
File “/home/FlStuGrp/ST12AStu/anaconda3/envs/hanlp/lib/python3.6/site-packages/tensorflow/python/keras/callbacks.py”, line 936, in set_params
self.epochs = params[‘epochs’]
KeyError: ‘epochs’

感谢反馈,这是升级tf2.3导致的兼容问题。已经修复:

This post was flagged by the community and is temporarily hidden.