AttributeError:模块“ tensorflow”不具有Keras属性“ name_scope”

Hen*_*rik 3 python keras tensorflow

我正在尝试运行脚本,但是在导入时已经很挣扎。此导入

from keras.preprocessing.image import save_img
Run Code Online (Sandbox Code Playgroud)

引发以下错误:

AttributeError: module 'tensorflow' has no attribute 'name_scope'.
Run Code Online (Sandbox Code Playgroud)

我正在使用以下软件包。

Keras                     2.2.2,                     
Keras-Applications        1.0.4,                   
Keras-Preprocessing       1.0.2,                   
tensorflow                1.9.0,                     
tensorflow-gpu            1.9.0                
Run Code Online (Sandbox Code Playgroud)

And*_*yko 5

我无法使用相同版本的keras和tensorflow进行复制,请重新安装keras和tensorflow,可以解决此问题,请使用以下命令:

pip install --upgrade pip setuptools wheel
pip install -I tensorflow
pip install -I keras
Run Code Online (Sandbox Code Playgroud)

注意:该-I参数代表忽略已安装的软件包。