英文:
Cannot import from Keras
问题
我想使用DeepLabCut中的函数***deeplabcut.evaluate_network(path_config_file,plotting=True)***来评估我的模型。
但是,当我运行代码时,我一直遇到这个问题:
No module named 'keras.legacy_tf_layers'
我不想更改TF版本,因为我正在使用GPU,而当前版本(2.10.0)更适合。
当前版本的Keras也是相同的(2.10.0)。
有人能帮忙吗?
我尝试导入模块,
from keras import legacy_tf_layers
from tensorflow.keras import legacy_tf_layers
但是它不起作用,
cannot import name 'legacy_tf_layers' 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'
答案1
得分: 0
似乎您正在使用最新版本的TensorFlow和Keras编写代码时参考了旧文档,导致出现此错误。
在TensorFlow 2.x
中,您可以使用以下代码导入layers:
from tensorflow.keras import layers
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论