Search code examples
tensorflowkerasimport

Cannot import from Keras


I want to evaluate my model in DeepLabCut, using the function : deeplabcut.evaluate_network(path_config_file,plotting=True)

But, I keep having this problem when runing the code: No module named 'keras.legacy_tf_layers'

I don't want to change the TF version as I am using the GPU and the current version which is (2.10.0) more adequate.

The current version of Keras is the same (2.10.0).

Can somebody help ?

I tried importing the module, from keras import legacy_tf_layers from tensorflow.keras import legacy_tf_layers

but it didn't work, cannot import name 'legacy_tf_layers' from 'keras'


Solution

  • It seems you are following old document for coding with latest tensorflow and keras versions which is showing this error.

    You can import layers using below code in Tensorflow 2.x:

    from tensorflow.keras import layers