ckiplab / ckipnlp

CKIP CoreNLP Toolkits
https://ckipnlp.readthedocs.io
GNU General Public License v3.0
114 stars 15 forks source link

Specify tensorflow version in readme and setup.py #22

Closed andreawwenyi closed 4 years ago

andreawwenyi commented 4 years ago

I was trying out ckipnlp with latest tensorflow (2.2.0), and when doing doc = CkipDocument(raw='中文字喔,啊哈哈哈'), I got the following error:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/Users/wyw/anaconda3/envs/ckip/lib/python3.7/site-packages/ckipnlp/pipeline/core.py", line 206, in get_ws
    text=self.get_text(doc)
  File "/Users/wyw/anaconda3/envs/ckip/lib/python3.7/site-packages/ckipnlp/driver/base.py", line 88, in __call__
    self.init()
  File "/Users/wyw/anaconda3/envs/ckip/lib/python3.7/site-packages/ckipnlp/driver/base.py", line 84, in init
    self._init()
  File "/Users/wyw/anaconda3/envs/ckip/lib/python3.7/site-packages/ckipnlp/driver/tagger.py", line 80, in _init
    self._core = ckiptagger.WS(_get_tagger_data(), disable_cuda=self._disable_cuda)
  File "/Users/wyw/anaconda3/envs/ckip/lib/python3.7/site-packages/ckiptagger/api.py", line 52, in __init__
    model = model_ws.Model(config)
  File "/Users/wyw/anaconda3/envs/ckip/lib/python3.7/site-packages/ckiptagger/model_ws.py", line 212, in __init__
    self.create_embedding()
  File "/Users/wyw/anaconda3/envs/ckip/lib/python3.7/site-packages/ckiptagger/model_ws.py", line 227, in create_embedding
    with tf.variable_scope(self.name, initializer=tf.random_normal_initializer(stddev=0.1)):
AttributeError: module 'tensorflow' has no attribute 'variable_scope'

After some googling I think the issue is that tensorflow has a major reform in r2.0. Afer downgradeing to tensorflow 1.15, I no longer got the error and can use ckipnlp without problem. Therefore I suggest adding the tensorflow version to README and setup.py to help other new users like myself.