python - importefficientnet.keras as efn - AttributeError: module 'keras.utils' has no attribute 'generic_utils'
问题描述
我正在尝试使用来自https://github.com/qubvel/segmentation_models的 EfficientNet 。
所以,我通过 pip 安装了这个:
!pip install git+https://github.com/qubvel/segmentation_models
然后我尝试导入efficientnet.keras
:
import efficientnet.keras as efn
并得到这个错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-57-61d736540c72> in <module>()
----> 1 import efficientnet.keras as efn
1 frames
/usr/local/lib/python3.6/dist-packages/efficientnet/__init__.py in init_keras_custom_objects()
69 }
70
---> 71 keras.utils.generic_utils.get_custom_objects().update(custom_objects)
72
73
AttributeError: module 'keras.utils' has no attribute 'generic_utils'
这很奇怪,因为它昨天工作没有任何问题,今天在一个笔记本上也是如此,但在其他笔记本上我得到了这个错误。有谁知道该怎么做?
解决方案
在我看来,您正在使用 Colab,他们今天可能已经升级了一些软件包,所以我们遇到了同样的错误。我通过以下方式将 Keras 和 Tenserflow 包降级到以前的包(我只猜到了版本号)解决了这个问题:
!pip install q tensorflow==2.1
!pip install q keras==2.3.1
推荐阅读
- java - adding Firebase packlages in flutter gives error
- mysql - Bash 中是否有任何 WORDCHARS 替代品?
- php - Xdebug Does Not Log Anything to Configured Log File
- javascript - How to align the labels on a circular axis with amCharts 4?
- ios - query with Fetch Request using CoreData on Swift
- c# - Changing the style of a border inside data template for the listbox item based on the alterationindex
- amazon-web-services - AWS CDK:Api 网关终端节点无法生成
- git - 我想将代码从本地存储库推送到两个不同的存储库
- swift - 当我制作自定义按钮和文本字段(以及其他 UI)时,如何找出我需要添加的属性并找出如何编写它们
- c# - 为什么身份验证 Cookie 对 [Authorize] 属性不起作用?