模块'keras.backend'没有属性'tf'



在运行旧脚本时,在更新 keras 和 tensorflow 后,我遇到了以下错误:

module 'keras.backend' has no attribute 'tensorflow_backend'

对于以下代码行

print(K.tensorflow_backend._get_available_gpus())

我开始理解这可能是版本不匹配的问题。KerasTensorflow的相应版本是

2.4.3
2.2.0
python - 3.7.5

我应该使用的正确版本兼容性/组合是什么,以克服此错误?

tensorflow_backend._get_available_gpus()在 TensorFlow 2.0 中不可用。

最好的办法是使用tf.config.list_physical_devicestf.config.experimental.list_physical_devices

GPU_list = tf.config.list_physical_devices('GPU')
# OR
GPU_list = tf.config.experimental.list_physical_devices('GPU')

你有错误的TensorFlow版本

install
TensorFlow Core v2.2.0 蟒

此版本包含 tf.keras.backend.backend((

https://www.tensorflow.org/api_docs/python/tf/keras/backend

我希望这是有帮助的

相关内容

最新更新