![](/img/trans.png)
[英]AttributeError: module 'keras.backend' has no attribute 'backend'
[英]module 'keras.backend' has no attribute 'tf'
在運行舊腳本時,在更新 keras 和 tensorflow 后,我遇到了以下錯誤:
module 'keras.backend' has no attribute 'tensorflow_backend'
對於以下代碼行
print(K.tensorflow_backend._get_available_gpus())
我開始明白這可能是版本不匹配的問題。 Keras和Tensorflow對應的版本是
2.4.3
2.2.0
python - 3.7.5
我應該使用什么正確的版本兼容性/組合來克服這個錯誤?
tensorflow_backend._get_available_gpus()
在 tensorflow 2.0 中不可用。
您最好的選擇是使用tf.config.list_physical_devices
或tf.config.experimental.list_physical_devices
GPU_list = tf.config.list_physical_devices('GPU')
# OR
GPU_list = tf.config.experimental.list_physical_devices('GPU')
你有 TensorFlow 錯誤的版本
安裝
TensorFlow 核心 v2.2.0 Python
此版本包含 tf.keras.backend.backend()
https://www.tensorflow.org/api_docs/python/tf/keras/backend
我希望這是有幫助的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.