AttributeError: 模块 'tensorflow.python.keras.utils.generic_utils' 没有属性 'populate_dict_with_module_objects' [英] AttributeError: module 'tensorflow.python.keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'
本文介绍了AttributeError: 模块 'tensorflow.python.keras.utils.generic_utils' 没有属性 'populate_dict_with_module_objects'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我导入 keras 时,即使昨天工作正常,也会弹出上述错误.
When I import keras, the error above pops up even though it was working fine yesterday.
我该如何解决这个错误?
How do I resolve this error?
我正在使用 Windows 10我的 keras 版本是:2.2.4我的 tensorflow 版本是:2.2.0rc2
I am working on windows 10 my keras version is: 2.2.4 my tensorflow version is: 2.2.0rc2
完整的错误回溯如下所示:
complete error traceback is seen below as such:
Traceback (most recent call last):
from keras import models
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packageskeras\__init__.py", line 3, in <module>
from . import utils
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packageskerasutils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packageskerasutilsconv_utils.py", line 9, in <module>
from .. import backend as K
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packageskerasackend\__init__.py", line 1, in <module>
from .load_backend import epsilon
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packageskerasackendload_backend.py", line 90, in <module>
from .tensorflow_backend import *
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packageskerasackend ensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packages ensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packages ensorflowpython\__init__.py", line 84, in <module>
from tensorflow.python import keras
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packages ensorflowpythonkeras\__init__.py", line 27, in <module>
from tensorflow.python.keras import models
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packages ensorflowpythonkerasmodels.py", line 24, in <module>
from tensorflow.python.keras import metrics as metrics_module
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packages ensorflowpythonkerasmetrics.py", line 37, in <module>
from tensorflow.python.keras.engine import base_layer
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packages ensorflowpythonkerasenginease_layer.py", line 51, in <module>
from tensorflow.python.keras import initializers
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packages ensorflowpythonkerasinitializers\__init__.py", line 127, in <module>
populate_deserializable_objects()
File "C:UsersworldAppDataLocalProgramsPythonPython38libsite-packages ensorflowpythonkerasinitializers\__init__.py", line 85, in populate_deserializable_objects
generic_utils.populate_dict_with_module_objects(
AttributeError: module 'tensorflow.python.keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'
推荐答案
change from keras import models
到 from tensorflow.keras import models
这为我解决了 tensorflow 2.5.0 的问题
change from keras import models
to from tensorflow.keras import models
this solved the problem for me with tensorflow 2.5.0
这篇关于AttributeError: 模块 'tensorflow.python.keras.utils.generic_utils' 没有属性 'populate_dict_with_module_objects'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文