keras: AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'
Needed to do: cp ./lib64/python3.9/site-packages/tensorflow/python/keras/utils/generic_utils.py ./lib/python3.9/site-packages/keras/utils/generic_utils.py
in my virtualenv.
tensorflow-2.5.0rc3-cp39-cp39-manylinux2010_x86_64.whl
Keras-2.4.3-py2.py3-none-any.whl
Python 3.9.4
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 42
- Comments: 42 (1 by maintainers)
Links to this issue
Commits related to this issue
- tests: fix keras - vis https://github.com/keras-team/keras/issues/14632 — committed to tqdm/tqdm by casperdcl 3 years ago
- tests: fix keras - vis https://github.com/keras-team/keras/issues/14632 — committed to tqdm/tqdm by casperdcl 3 years ago
- - update pillow version - update code for latest dependency issue in keras==2.4.3 and tensorflow==2.5.0 (https://github.com/keras-team/keras/issues/14632) Signed-off-by: ericy <ericy@infuseai.io> — committed to InfuseAI/model-deployment-examples by ggosiang 3 years ago
- Merge pull request #26 from InfuseAI/dependabot/pip/keras_mnist/tensorflow-2.5.0 - bump tensorflow from 2.4.0 to 2.5.0 - update dependency conflicts in h5py - update prediction code for latest depe... — committed to InfuseAI/model-deployment-examples by ggosiang 3 years ago
- fix according to https://github.com/keras-team/keras/issues/14632 — committed to haven-jeon/PyKoSpacing by haven-jeon 3 years ago
- Fix bug with keras imports Thanks to this had to run a fun pip install force reinstall https://github.com/keras-team/keras/issues/14632 Solution found here after reinstalling tensorflow with updated... — committed to theodonkulus/ECE657 by theodonkulus 3 years ago
- remove `import keras` - fixes https://github.com/keras-team/keras/issues/14632 — committed to ravnoor/ANTsPyNet by ravnoor 3 years ago
- Update requirements_mac.txt going back to Tensorflow 2.2.1 as 2.5.1 is not compatible with Keras version. For details see https://github.com/keras-team/keras/issues/14632 — committed to HelmchenLabSoftware/Cascade by hluetck 3 years ago
I’ve gotten around this by uninstalling keras and changing anything I import from keras to instead import from tensorflow.keras
So this:
became this:
and then I didn’t have to amend the rest of my work
Replaced everything of
keras
totf.keras
! Using Libs:Change layers as :
Change Optimizer:
Change Operations:
dear keras-team, do you have any plan to release a newer stable version of Keras? Currently, the stable Keras
2.4.3
does not work with TensorFlow2.5.0
due to the error reported in this issue.Had the same issue, after I uninstalled all tensorflows and keras-nightly, I reinstalled tensorflow with
pip install tensorflow --upgrade --force-reinstall
and it worked.replace:
import keras.utils as generic_utils
with:
import tensorflow.python.keras.utils as generic_utils
Trust me the above might be a long solution but will work in the long run.
I’m not sure the status of solving the underlying issue(s) for this bug, but something I’ve discovered is that the order of installing packages matters here. When creating a new virtual environment (Python 3.8), using the following command
pip install keras tensorflow pillow
results in the traceback below when importing some modules. However, if you instead do:
the error doesn’t occur.
Traceback:
Same Issue I had also seen,…
I update the importing header keras instead with tensorflow… Its working… all my model
from tensorflow.keras import Sequential from tensorflow.keras.models import load_model from tensorflow.keras.layers import Dense,LSTM
THANK YOU SO MUCH!!! YOU’RE A GOD!!
Yes it worked for me thanks everyone. Replacing keras with tensorflow.keras will definitely run your program
@aliwelchoo @khanfarhan10 The
tensorflow.keras
works fine, but usingkeras
directly is the only way to getplaidml-keras
and using Metal and AMD GPU during learning on Macpip install keras-self-attention==0.50.0
this is works for me
Closing this issue since its resolved. Feel free to post a new issue if still have problems. Thanks!
Where and what is the file i must edit this?
If you work on ubuntu and conda:
cp ./anaconda3/envs/{ENV}/lib/python3.9/site-packages/tensorflow/python/keras/utils/generic_utils.py ./anaconda3/envs/{ENV}/lib/python3.9/site-packages/keras/utils/generic_utils.py
{ENV} = your conda environment name
This is the way to go. Tensorflow will ensure the compatibility with keras if you use the sub-package.
This really solved the problem here! Thankssss
Thanks for responding, I used tensorflow.keras instead of keras and it worked
On Wed, Jun 2, 2021, 15:28 Ch.V.S. Phaneendhra @.***> wrote:
Hi Farhan,
Yeah I did that and it worked. Thanks very much
On Tue, Jun 1, 2021, 09:30 Farhan Hai Khan @.***> wrote: