当我尝试在 Keras 中导入 Tokenizer()
函数时,出现以下错误。
我正在关注 Keras 官方文档 https://keras.io/preprocessing/text/#tokenizer
import keras
tokenizer = keras.preprocessing.text.Tokenizer()
出现这样的错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'keras.preprocessing' has no attribute 'text'
使用 Keras 版本“2.1.3”
我哪里做错了?
最佳答案
你想要
from keras.preprocessing import text
tokenizer = text.Tokenizer(...)
原因是 keras/preprocessing/__init__.py
没有导入或公开 text
子模块
关于python - 属性错误: module 'keras.preprocessing' has no attribute 'text' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48561909/