在 ‘init.py | init.py’ 中找不到引用 ‘keras’
可能是因为 keras 库没有被正确安装或者没有被正确导入。
从 TensorFlow 2.0 开始,Keras 被整合为 TensorFlow 的一个子模块,因此应当通过 TensorFlow 来使用 Keras。
解决
首先,确保你已经安装了 TensorFlow。由于 Keras 现在是 TensorFlow 的一部分,所以不需要单独安装 Keras,不需要将keras降低版本。
只需要将keras.preprocessing.sequence改为keras_preprocessing.sequence即可。
from keras.preprocessing.sequence import pad_sequences
改为
from keras_preprocessing.sequence import pad_sequences