Home > Blockchain >  ImportError: cannot import name 'Layer' from 'keras.engine'
ImportError: cannot import name 'Layer' from 'keras.engine'

Time:07-20

I am facing a difficulty in solving this error. I want to pass the Layer object to a class in python,I am facing an import error. Here is the error message.

Traceback (most recent call last):
  File "/Users/mianafra/Documents/NLP/D2V-BiGRU-CRF/annotate_docs.py", line 3, in <module>
    from wrap import Sequence
  File "/Users/mianafra/Documents/NLP/D2V-BiGRU-CRF/wrap.py", line 6, in <module>
    from models_d2v import BiLSTMCRFD2V_to_dense, save_model, load_model
  File "/Users/mianafra/Documents/NLP/D2V-BiGRU-CRF/models_d2v.py", line 10, in <module>
    from layers import CRF
  File "/Users/mianafra/Documents/NLP/D2V-BiGRU-CRF/layers.py", line 9, in <module>
    from keras.engine import Layer
ImportError: cannot import name 'Layer' from 'keras.engine'   

CodePudding user response:

Make sure you have installed the correct Keras version required by the project.

If it's this D2V-BiGRU-CRF project, it seems to be

keras==2.2.0

CodePudding user response:

I think there is something wrong with your tensorflow installation, have you tried to reinstall tensorflow? maybe try look here: https://github.com/tensorflow/tensorflow/issues/24847

  • Related