python - 无法导入名称 'tf2'

标签 python tensorflow keras

我创建了一个 v.environment,其中有 Python 版本 3.6.5,并安装了 tensorflow-gpu
TensorFlow的版本是1.4.0,Keras的版本是2.6.0。
当我在脚本 import keras 上写入时,出现以下错误:

ImportError: cannot import name 'tf2'

你有什么想法吗?

最佳答案

来自评论

Here the problem caused by the TF is too old, and the keras is too new. Your choice is to downgrade keras to 2.2.1, or use newer version of tf (paraphrased by Vinson Ciawandy & homomathematicus)

关于python - 无法导入名称 'tf2',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69132718/

相关文章:

python - 使用 toctree 的自动摘要还列出了导入的成员

python - 获取自定义搜索的 cx ID,Google API - Python

python - 使用Flask框架是否需要使用virtualenv?

python - 加载 SavedModel 比加载 tf.train.Saver 检查点慢很多

python - 在 TensorFlow 中有什么方法可以初始化未初始化的变量吗?

python - 无法对多行进行排序

java - TensorFlow Lite 的 Float32 输出值如何表示图像?

python - 如何将 Keras 模型保存为卡住图?

python - Keras 预测每次返回相同的结果

python - 警告 :tensorflow:Layer my_model is casting an input tensor from dtype float64 to the layer's dtype of float32, 这是 TensorFlow 2 中的新行为