. Advertisement .
..3..
. Advertisement .
..4..
When you start a project, there are many steps that need to be accomplished. This article will show you how to easily fix the error: AttributeError: module ‘keras.engine’ has no attribute ‘Layer’ in Python.
What is “AttributeError: module ‘keras.engine’ has no attribute ‘Layer’ in Python”?
You are trying to run the code and facing the following error in your terminal.
AttributeError: module 'keras.engine' has no attribute 'Layer'
The Effective Methods For The Error “AttributeError: module ‘keras.engine’ has no attribute ‘Layer’ in Python”.
Method 1: Replace keras.engine
with keras.engine.topology
You need to replace this code.
import keras.engine as KE
And use the following code.
import keras.engine.topology as KE
Your problem should now be resolved.
Solution 2: Use These Versions
First of all, uninstall the following versions:
pip uninstall keras -y
pip uninstall keras-nightly -y
pip uninstall keras-Preprocessing -y
pip uninstall keras-vis -y
pip uninstall tensorflow -y
pip uninstall h5py -y
Then, you need to use this version of h5py, Keras, and Tensorflow.
!pip install tensorflow==1.13.1
!pip install keras==2.0.8
!pip install h5py==2.10.0
Your problem should now be resolved.
Solution 3:
In one case, there is a line use leyer like ProposalLayer(KE.Layer), replace KE.Layer with :
import keras.layers as KL
And you change all KE to KL
Conclusion
The simple approaches presented above are our simple solutions to the aforementioned major error: “AttributeError: module ‘keras.engine’ has no attribute ‘Layer’ in Python“.
Please leave all your concerns in the comments section if you have any further questions. I wish you all an effective day with your tool.
Leave a comment