AttributeError: module 'tensorflow' has no attribute 'python' in Keras Tensorflow

AttributeError: module 'tensorflow' has no attribute 'python' in Keras Tensorflow

系统信息:

我正在研究 keras tensorflow 后端的 siamese 算法。我已经按如下方式导入了 keras 后端,它显示了上面的属性错误。这可能是什么原因以及如何避免这个问题?

import tensorflow.python.keras.backend as K

AttributeError: module 'tensorflow' has no attribute 'python'

表示在模块'tensorflow'中,不存在名为'python'的属性。我相信您真的不需要导入 python 作为模块。试试这个:

import tensorflow.keras.backend as K