在 PyCharm 中使用 tensorflow2.0 时出现错误“找不到参考”

vzZ*_*vzZ 7 pycharm tensorflow2.0

当我从 tensorflow 导入包、类或方法时显示以下错误:

Cannot find reference 'keras' in '__init__.py' less... (Ctrl+F1) 
Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
Run Code Online (Sandbox Code Playgroud)

使用 tensorflow 的预览版本时不会发生此问题。但是,程序仍然可以正常运行。我在“tensorflow.keras”中发现包“keras”,在编码界面中出现此错误,但是当我更改为导入“tensorflow.python.keras”时它无法运行。我该如何解决这个问题?

我正在使用 tensorflow 2.0.0alpha 和最新版本的 Pycharm

PyCharm 2018.3.5 (Professional Edition)
Build #PY-183.5912.18, built on February 26, 2019
Licensed to xxx
Subscription is active until May 14, 2019
For educational use only.
JRE: 1.8.0_152-release-1343-b28 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Run Code Online (Sandbox Code Playgroud)

cad*_*ebe 1

我目前正在使用已安装的 TensorFlow 2 beta 版本,并用于为我从 keras 导入的包获取红色曲线(例如,当使用from tensorflow.keras import datasets, layers, modelsPycharm 无法理解数据集、层或模型时)。

我发现手动导入keras包消除了错误突出显示。转到 Project Interpreter(cmd + ,在 macOS 上),单击+按钮,在搜索栏中输入“keras”,选择您需要的版本,然后单击“安装包”按钮。