无法从Keras导入

huangapple go评论47阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年5月10日 22:54:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76219895.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定