Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用foolNLTK时出现错误“ModuleNotFoundError: No module named 'tensorflow.contrib'” #68

Open
newmrxu opened this issue May 19, 2020 · 2 comments

Comments

@newmrxu
Copy link

newmrxu commented May 19, 2020

我的环境:anaconda 3.7
tensorflow: 2.2.0

程序:

import fool

text = "林语堂是中国最好的英文作家。"
print(fool.cut(text))
@Sanchez2020
Copy link

tensorflow2.0及以上版本没有这个模块了。tensorflow/tensorflow#30794

@qh-deng
Copy link

qh-deng commented Sep 26, 2020

tensorflow2.0及以上版本一些API发生了变化,卸载安装1.X的版本就可以使用。如果不想卸载tensorflow2.0,可以做以下修改,亲测可用,本人修改后运行fool.cut(text)和fool.analysis(text)都没问题:

1.安装tensorflow_addons: pip install tensorflow-addons
2.找到Anaconda3下的Lib/site-packages/fool
3.修改model.py文件中的代码:
第8行改为from tensorflow_addons.text import viterbi_decode
4.修改predictor.py文件中的代码:
第8行改为from tensorflow_addons.text import viterbi_decode
第32行改为with tf.io.gfile.GFile(path, "rb") as f:
第33行改为graph_def = tf.compat.v1.GraphDef()
第53行改为self.sess = tf.compat.v1.Session(graph=self.graph)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants