当我从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.
使用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
答案 0 :(得分:0)
我目前已安装TensorFlow 2 beta版,并用于从我从keras导入的软件包中获取红色弯线(例如,使用from tensorflow.keras import datasets, layers, models
Pycharm无法理解数据集,层或模型)。
我发现手动导入keras
软件包摆脱了错误提示。转到Project Interpreter(在MacOS上为cmd +),单击+
按钮,在搜索栏中键入“ keras”,选择所需的版本,然后单击“ Install Package”按钮。>