我已经在colab上很好地运行了DL模型,直到上周五他们升级了系统。我收到此错误:
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in _get_default_graph()
65 try:
---> 66 return tf.get_default_graph()
67 except AttributeError:
AttributeError: module 'tensorflow' has no attribute 'get_default_graph'
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
8 frames
/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in _get_default_graph()
67 except AttributeError:
68 raise RuntimeError(
---> 69 'It looks like you are trying to use '
70 'a version of multi-backend Keras that '
71 'does not support TensorFlow 2.0. We recommend '
RuntimeError:您似乎正在尝试使用不支持TensorFlow 2.0的多后端Keras版本。我们建议使用
tf.keras
,或者降级为TensorFlow 1.14。
我当前在Mac(Mojave)上运行Python 3.7.6版本。我的机器上正在运行TensorFlow 2.0.0版本。
我在使用Google Colab时也遇到了同样的问题。因此,我要做的是从tensorflow.keras模块导入所有模块,而不是仅使用通过keras进行调用的传统方法。
例如而不是'from keras.models import Sequential'使用'from tensorflow.keras import Sequential'
'从keras.layers导入Conv2D,MaxPool2D,密集,展平,辍学'使用'从tensorflow.keras.layers导入Conv2D,MaxPool2D,平坦,辍学,密集'
所以,我的新代码看起来像这样。 My new code.