AttributeError: keras.backend ,没有属性 'eager' [英] AttributeError: keras.backend ,no attribute 'eager'

查看:47
本文介绍了AttributeError: keras.backend ,没有属性 'eager'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 python 3.8.2、keras 2.3.1 和 tensorflow 2.2.0rc4.只需使用以下代码:

导入keras从 keras.models 导入顺序

我有这个错误:AttributeError: 部分初始化的模块 'keras.backend' 没有属性 'eager'(很可能是由于循环导入)

如果我使用:

导入tensorflow

from tensorflow.keras import ....

新错误:

AttributeError: 部分初始化的模块 'tensorflow.python.framework.ops' 没有属性 'register_tensor_conversion_function'(很可能是由于循环导入)

完整回溯:在此处输入图片描述

在此处输入图片说明

解决方案

我的建议是重新安装软件包.有时这是由于安装问题造成的.

使用以下代码执行此操作

卸载tensorflow

<块引用>

pip 卸载 tensorflow

需要最新的 pip

<块引用>

pip install --upgrade pip

单独安装keras

<块引用>

pip 安装 Keras

CPU 和 GPU 的当前稳定版本

<块引用>

pip 安装张量流

试试这个,希望对你有帮助.

I'm using python 3.8.2 , keras 2.3.1 and tensorflow 2.2.0rc4 . just with the following code :

import keras
from keras.models import sequential

I have this error : AttributeError: partially initialized module 'keras.backend' has no attribute 'eager' (most likely due to a circular import)

if I use :

import tensorflow

or

from tensorflow.keras import ....

new error :

AttributeError: partially initialized module 'tensorflow.python.framework.ops' has no attribute 'register_tensor_conversion_function' (most likely due to a circular import)

full traceback: enter image description here

enter image description here

解决方案

My suggestion is to reinstall the package. Sometimes this happens due to the installation problem.

Use the following code to do so

Uninstall tensorflow

pip uninstall tensorflow

Requires the latest pip

pip install --upgrade pip

To install keras as separate package

pip install Keras

Current stable release for CPU and GPU

pip install tensorflow

Try this and hope this helps you.

这篇关于AttributeError: keras.backend ,没有属性 'eager'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆